Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services
https://seldaek.github.io/monolog/
MIT License
20.95k stars 1.9k forks source link

[NormalizerFormatter] Avoid throwing an exception when the toString call fails #1868

Closed VincentLanglet closed 4 months ago

VincentLanglet commented 7 months ago

HI @Seldaek

This is an improvement of https://github.com/Seldaek/monolog/issues/673

When a __toString method call throws an exception (which should occurs as few as possible), the Normalizer is throwing an exception too. I believe this behavior is wrong because:

Also, I have the following situation when using DoctrineFixtureBundle:

As soon as I comment the toString method in my entity, I get the correct error. Imho, if monolog cannot use the toString method, he shouldn't change the "error behavior" and fallback to jsonEncode like the tostring method doesn't exist.

WDYT ?

VincentLanglet commented 5 months ago

Friendly ping @Seldaek if you find some time to take a look :)

Seldaek commented 4 months ago

Thanks yeah probably makes sense to avoid failures.