mirror of
https://github.com/Seldaek/monolog.git
synced 2026-04-27 00:25:50 +03:00
[GH-ISSUE #1434] Define custom handlers at runtime for daemons without duplicate log records #602
Labels
No labels
Bug
Documentation
Feature
Needs Work
Support
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/monolog#602
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Clivern on GitHub (Mar 4, 2020).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1434
Monolog version 2
I am using monolog with a daemon and i am wondering if there is anyway to define handlers with identification string at runtime.
if we do something like this
handlers will increase at runtime at each iteration and we got a duplicate log records
the only way i come up with is to reset handlers or naive function to check if stream handler already there.
is there is anyway i can do like
$log->handlerExist(handler~ident~here)that will work with all possible handlers :). if there is a lot of logic/classes inside while call, I will need a way to identify if the previous call or previous class already registered/configured that handler.May be this not requested a lot or usually handlers not configured at runtime but it would be a nice to have this & can be done on a backward compatible way or a workaround.
@Seldaek commented on GitHub (May 11, 2020):
IMO you should rather do
$log->pushHandler($newHandler); ...do stuff here... $log->popHandler();or if you can not trust this to work because some code pushes handlers without popping them within your loop, then you can also check for existence usingin_array($handler, $log->getHandlers(), true)I would say... this only requires you keep track of the $handler instance you added somehow.