Seldaek / monolog

Sends your logs to files, sockets, inboxes, databases and various web services

Home Page:https://seldaek.github.io/monolog/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LogRecord "extra" data leaking between handlers

cosminardeleanu opened this issue · comments

Monolog version: latest released v3.


Context:

  • Let's say i have 3 handlers attached to monolog logger: file handler, slack handler, elastic search handler.
    • Note that each handler can push its own processor, which can alter the LogRecord entity.
  • On the elastic search handler, we need extra info, so push a processor to add them, (stupid example: $logRecord->extra['new_entry_just_for_elastic_search'] = 'stuff';
    • This "extra" data i also available for file handler and slack handler.
    • Basically i will get in slack handler and file handler, this extra that was supposed to be only for elastic search handler.

Why this is happening?

  • LogRecord is passed by reference, to each handler.
  • LogRecord accepts to alter data from extra, so if one handlers manages to alter this object, rest of remaining handlers, will use the altered object.

Created PR to fix this -> #1819