Skip to content

Commit 3a76000

Browse files
committed
minor #17454 [Logger] Use Monolog\LogRecord object instead of array for log processor (94noni)
This PR was merged into the 6.1 branch. Discussion ---------- [Logger] Use Monolog\LogRecord object instead of array for log processor Leverage new monolog as log records object (monolog >= v3) https://github.com/Seldaek/monolog/releases/tag/3.0.0 if we decide to keep the array (monolog <= v2), how can we document this? with inline comments ? with 2 code block? see also https://packagist.org/packages/monolog/monolog/php-stats#3.0 that is why I target sf 6.1+ thx Commits ------- 3b4ebc0 Update processors.rst
2 parents 20e88b5 + 3b4ebc0 commit 3a76000

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

logging/processors.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ using a processor::
3232
}
3333

3434
// this method is called for each log record; optimize it to not hurt performance
35-
public function __invoke(array $record)
35+
public function __invoke(LogRecord $record): LogRecord
3636
{
3737
try {
3838
$session = $this->requestStack->getSession();
@@ -45,7 +45,7 @@ using a processor::
4545

4646
$sessionId = substr($session->getId(), 0, 8) ?: '????????';
4747

48-
$record['extra']['token'] = $sessionId.'-'.substr(uniqid('', true), -8);
48+
$record->extra['token'] = $sessionId.'-'.substr(uniqid('', true), -8);
4949

5050
return $record;
5151
}

0 commit comments

Comments
 (0)