diff --git a/CHANGELOG.md b/CHANGELOG.md index dc0465803404f296ff58fb0174e387a10cdc8536..01e3743415628b5691ea9c967212d31d8cbccea6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v0.1.75 + +* The logging context now includes the active symfony route name + # v0.1.59 * api-docs: compatibility fixes for relay-auth-bundle v0.1.12 diff --git a/src/Logging/LoggingProcessor.php b/src/Logging/LoggingProcessor.php index 0b6c309f90a30e5a71d495669a4278fd14943d29..a2268da8302d2a97d99cfef2961eb2a0d49279df 100644 --- a/src/Logging/LoggingProcessor.php +++ b/src/Logging/LoggingProcessor.php @@ -55,6 +55,11 @@ final class LoggingProcessor $request->attributes->set($requestAttributeKey, $requestId); } $record['context']['relay-request-id'] = $requestId; + + $route = $request->attributes->get('_route'); + if ($route !== null) { + $record['context']['relay-route'] = $route; + } } return $record; diff --git a/tests/Logging/LoggingProcessorTest.php b/tests/Logging/LoggingProcessorTest.php index 7db5c12ba485196829ae1e4b0e3b5805bce7bb8b..ec0a6ae3fea6c3fd8593d54fc5b3b55a892bda90 100644 --- a/tests/Logging/LoggingProcessorTest.php +++ b/tests/Logging/LoggingProcessorTest.php @@ -42,6 +42,18 @@ class LoggingProcessorTest extends WebTestCase $this->assertSame(['message' => 'foobar', 'context' => ['relay-session-id' => 'logging-id']], $record); } + public function testRoute() + { + $stack = new RequestStack(); + $request = new Request(); + $request->attributes->set('_route', 'some_route'); + $stack->push($request); + $processor = new LoggingProcessor(new TestUserSession('log'), $stack); + $record = ['message' => 'foobar']; + $record = $processor->__invoke($record); + $this->assertSame('some_route', $record['context']['relay-route']); + } + public function testMaskUserId() { $processor = new LoggingProcessor(new TestUserSession('some-random-user-id'), new RequestStack());