Skip to content

Commit

Permalink
bug #5656 Fix monolog line formatter in logging cookbook example. (vm…
Browse files Browse the repository at this point in the history
…arquez)

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.
  • Loading branch information
wouterj committed Sep 5, 2015
2 parents 1f79d9d + 6c6ed2a commit 653b6d4
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cookbook/logging/monolog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ using a processor.
monolog.formatter.session_request:
class: Monolog\Formatter\LineFormatter
arguments:
- "[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%%\n"
- "[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%\n"
monolog.processor.session_request:
class: Acme\MyBundle\SessionRequestProcessor
Expand Down Expand Up @@ -375,7 +375,7 @@ using a processor.
<service id="monolog.formatter.session_request"
class="Monolog\Formatter\LineFormatter">
<argument>[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%%&#xA;</argument>
<argument>[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%&#xA;</argument>
</service>
<service id="monolog.processor.session_request"
Expand Down Expand Up @@ -405,7 +405,7 @@ using a processor.
'monolog.formatter.session_request',
'Monolog\Formatter\LineFormatter'
)
->addArgument('[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%%\n');
->addArgument('[%%datetime%%] [%%extra.token%%] %%channel%%.%%level_name%%: %%message%% %%context%% %%extra%%\n');
$container
->register(
Expand Down

0 comments on commit 653b6d4

Please sign in to comment.