Skip to content

Commit d1d9e21

Browse files
feat: Add the rpcName to the logged event (#630)
1 parent 2606c4e commit d1d9e21

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/Logging/LoggingTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ private function logRequest(RpcLogEvent $event): void
3636
'severity' => strtoupper(LogLevel::DEBUG),
3737
'processId' => $event->processId ?? null,
3838
'requestId' => $event->requestId ?? null,
39+
'rpcName' => $event->rpcName ?? null,
3940
];
4041

4142
$debugEvent = array_filter($debugEvent, fn ($value) => !is_null($value));

tests/Logging/LoggingTraitTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ public function testLogResponse()
8686
$this->assertEquals($event->headers, $parsedDebugEvent['jsonPayload']['response.headers']);
8787
}
8888

89+
public function testRpcNameShouldBeIncluded()
90+
{
91+
$event = $this->getNewLogEvent();
92+
$event->headers = ['Thisis' => 'a header'];
93+
$this->loggerContainer->logRequest($event);
94+
95+
$buffer = $this->getActualOutput();
96+
97+
$parsedDebugEvent = json_decode($buffer, true);
98+
$this->assertEquals($event->rpcName, $parsedDebugEvent['rpcName']);
99+
}
100+
89101
private function getNewLogEvent(): RpcLogEvent
90102
{
91103
$event = new RpcLogEvent();

0 commit comments

Comments
 (0)