Skip to content
Snippets Groups Projects
Commit bb0d8a8a authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

LoggingProcessor: add the symfony route to the context

With many bundles active it might not be clear which bundle
is the cause for the logging message. Add the current active
Symfony route to make it a bit more clear.
parent 1d43096e
Branches
Tags
No related merge requests found
Pipeline #231243 passed
# v0.1.75
* The logging context now includes the active symfony route name
# v0.1.59 # v0.1.59
* api-docs: compatibility fixes for relay-auth-bundle v0.1.12 * api-docs: compatibility fixes for relay-auth-bundle v0.1.12
......
...@@ -55,6 +55,11 @@ final class LoggingProcessor ...@@ -55,6 +55,11 @@ final class LoggingProcessor
$request->attributes->set($requestAttributeKey, $requestId); $request->attributes->set($requestAttributeKey, $requestId);
} }
$record['context']['relay-request-id'] = $requestId; $record['context']['relay-request-id'] = $requestId;
$route = $request->attributes->get('_route');
if ($route !== null) {
$record['context']['relay-route'] = $route;
}
} }
return $record; return $record;
......
...@@ -42,6 +42,18 @@ class LoggingProcessorTest extends WebTestCase ...@@ -42,6 +42,18 @@ class LoggingProcessorTest extends WebTestCase
$this->assertSame(['message' => 'foobar', 'context' => ['relay-session-id' => 'logging-id']], $record); $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() public function testMaskUserId()
{ {
$processor = new LoggingProcessor(new TestUserSession('some-random-user-id'), new RequestStack()); $processor = new LoggingProcessor(new TestUserSession('some-random-user-id'), new RequestStack());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment