[GH-ISSUE #1184] Question: why the LineFormatter doesn't try to recover json encoding errors? #488

Closed
opened 2026-03-04 02:15:25 +03:00 by kerem · 4 comments
Owner

Originally created by @mmenozzi on GitHub (Aug 4, 2018).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1184

Like stated in the subject: why the LineFormatter doesn't try to recover json encoding errors?
I mean something that has already been done with https://github.com/Seldaek/monolog/pull/683 for the NormalizerFormatter.

Is simply because anyone didn't have time to do such implementation or there are other reasons?

Originally created by @mmenozzi on GitHub (Aug 4, 2018). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1184 Like stated in the subject: why the LineFormatter doesn't try to recover json encoding errors? I mean something that has already been done with https://github.com/Seldaek/monolog/pull/683 for the NormalizerFormatter. Is simply because anyone didn't have time to do such implementation or there are other reasons?
kerem 2026-03-04 02:15:25 +03:00
  • closed this issue
  • added the
    Feature
    label
Author
Owner

@Seldaek commented on GitHub (Nov 4, 2018):

I think it's mostly because nobody did it yes.. Feel free to PR

<!-- gh-comment-id:435685753 --> @Seldaek commented on GitHub (Nov 4, 2018): I think it's mostly because nobody did it yes.. Feel free to PR
Author
Owner

@mmenozzi commented on GitHub (Nov 4, 2018):

Ok I’ll do it

<!-- gh-comment-id:435696800 --> @mmenozzi commented on GitHub (Nov 4, 2018): Ok I’ll do it
Author
Owner

@mmenozzi commented on GitHub (Nov 5, 2018):

Hi @Seldaek ,
sorry but what I said before it's not correct.

The NormalizerFormatter contains the logic to try to recover from json encoding errors but this logic isn't used in the NormalizerFormatter itself.

That logic is called from the NormalizerFormatter::toJson method but only if the $ignoreErrors parameters is false. Inside the NormalizerFormatter the toJson method is always called with $ignoreErrors set to true.

I found that the NormalizerFormatter::toJson method with $ignoreErrors set to false is called only in the GelfMessageFormatter, LogstashFormatters and WildfireFormatter formatters.

So the question now is: what we would like to do? Should the LineFormatter (or maybe also others) tries to recover json encoding errors or not?

<!-- gh-comment-id:435977647 --> @mmenozzi commented on GitHub (Nov 5, 2018): Hi @Seldaek , sorry but what I said before it's not correct. The `NormalizerFormatter` contains the logic to try to recover from json encoding errors but this logic isn't used in the `NormalizerFormatter` itself. That logic is called from the `NormalizerFormatter::toJson` method but only if the `$ignoreErrors` parameters is `false`. Inside the `NormalizerFormatter` the `toJson` method is always called with `$ignoreErrors` set to `true`. I found that the `NormalizerFormatter::toJson` method with `$ignoreErrors` set to `false` is called only in the `GelfMessageFormatter`, `LogstashFormatters` and `WildfireFormatter` formatters. So the question now is: what we would like to do? Should the `LineFormatter` (or maybe also others) tries to recover json encoding errors or not?
Author
Owner

@Seldaek commented on GitHub (Nov 19, 2018):

Hmm I guess maybe yes. I think the whole formatter thing needs to be cleaned up in 2.0 but it's a rather complex task :/

<!-- gh-comment-id:440081815 --> @Seldaek commented on GitHub (Nov 19, 2018): Hmm I guess maybe yes. I think the whole formatter thing needs to be cleaned up in 2.0 but it's a rather complex task :/
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#488
No description provided.