Seldaek / monolog

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

Fix LogRecord "extra" data leaking between handlers #1819

Closed cosminardeleanu closed 1 year ago

cosminardeleanu commented 1 year ago

Context:

Why this is happening?

cosminardeleanu commented 1 year ago

@Seldaek ^^

aistis- commented 1 year ago

I confirm the issue persists with 3.4.0. Waiting for the merge 🤞

stof commented 1 year ago

@Seldaek with the migration to an object in Monolog 3, this is indeed an issue for handler-level processors rather than logger-level processors. Should the logger clone the record before calling the handler ?

Seldaek commented 1 year ago

Yeah I think it'd be better to clone.. both in Logger and in GroupHandler and related handlers which fan out records to nested handlers. Otherwise the problem is just shifted one problem lower.

stof commented 1 year ago

indeed, fan-out handlers also need to clone.

Seldaek commented 1 year ago

Alright I think with my commit it should take care of it for all cases. I hope I didn't forget any fan-out handler.