Skip to content

Commit 653b6d4

Browse files
committed
bug #5656 Fix monolog line formatter in logging cookbook example. (vmarquez)
This PR was merged into the 2.3 branch. Discussion ---------- Fix monolog line formatter in logging cookbook example. | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | all | Fixed tickets | After [Adding some extra Data in the Log Messages](http://symfony.com/doc/current/cookbook/logging/monolog.html#adding-some-extra-data-in-the-log-messages), logs were missing some detail (like missing translation tokens on translation.WARNING messages). I've corrected the line formatter adding missing tokens taken from [Monolog/Formatter/LineFormatter.php](https://github.com/Seldaek/monolog/blob/master/src/Monolog/Formatter/LineFormatter.php). Example, log entries before adding extra data: ``` [2015-08-25 14:24:58] translation.WARNING: Translation not found. {"id":"GeoCountryReg.labels.imageFile1","domain":"messages","locale":"es"} [] ``` And after: ``` [2015-08-25 14:27:29] [cutptr3q-f0d64b15] translation.WARNING: Translation not found. ``` Desired effect was: ``` [2015-08-25 14:36:18] [cutptr3q-3b0c7c83] translation.WARNING: Translation not found. {"id":"GeoCountryReg.labels.imageFile1","domain":"messages","locale":"es"} [] ``` Commits ------- 6c6ed2a Fix monolog line formatter in logging cookbook example.
2 parents 1f79d9d + 6c6ed2a commit 653b6d4

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cookbook/logging/monolog.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ using a processor.
343343
monolog.formatter.session_request:
344344
class: Monolog\Formatter\LineFormatter
345345
arguments:
346-
- "[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%%\n"
346+
- "[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%\n"
347347
348348
monolog.processor.session_request:
349349
class: Acme\MyBundle\SessionRequestProcessor
@@ -375,7 +375,7 @@ using a processor.
375375
<service id="monolog.formatter.session_request"
376376
class="Monolog\Formatter\LineFormatter">
377377
378-
<argument>[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%%&#xA;</argument>
378+
<argument>[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%&#xA;</argument>
379379
</service>
380380
381381
<service id="monolog.processor.session_request"
@@ -405,7 +405,7 @@ using a processor.
405405
'monolog.formatter.session_request',
406406
'Monolog\Formatter\LineFormatter'
407407
)
408-
->addArgument('[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%%\n');
408+
->addArgument('[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%\n');
409409
410410
$container
411411
->register(

0 commit comments

Comments
 (0)