[GH-ISSUE #1100] DeduplicationHandler with cli app instead of cgi #449

Closed
opened 2026-03-04 02:15:07 +03:00 by kerem · 1 comment
Owner

Originally created by @never1sdead on GitHub (Dec 26, 2017).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/1100

I'm using DeduplicationHandler in my socket application.

The problem is that DepulicationHandler is a BufferHandler with null bufferLimit(unlimited). It will keep the logs indefinitely untill I shut down the process.

Now the only way to flush the error logs is to expose the refrence to DepulicationHandler instance and call flash() every 60s in a timer, which isn't not quite convenient when there are a lot of loggers.

It would be great to allow DepulicationHandler to use a time based bufferLimit. Like flushing every 60s when next log arrives. I think it can be done by overriding the handler() method.

Originally created by @never1sdead on GitHub (Dec 26, 2017). Original GitHub issue: https://github.com/Seldaek/monolog/issues/1100 I'm using DeduplicationHandler in my socket application. The problem is that DepulicationHandler is a BufferHandler with null bufferLimit(unlimited). It will keep the logs indefinitely untill I shut down the process. Now the only way to flush the error logs is to expose the refrence to DepulicationHandler instance and call `flash()` every 60s in a timer, which isn't not quite convenient when there are a lot of loggers. It would be great to allow DepulicationHandler to use a time based bufferLimit. Like flushing every 60s when next log arrives. I think it can be done by overriding the `handler()` method.
kerem 2026-03-04 02:15:07 +03:00
  • closed this issue
  • added the
    Feature
    label
Author
Owner

@Seldaek commented on GitHub (Jun 18, 2018):

I think the best solution here would be to call close() on it at the end of every "job" or whatever you are doing on the CLI. Which would flush every time as if it was a web request in a fcgi context. Monolog 2.0 should have close() available on the Logger instance to facilitate this, but in 1.x you can already call close on the DeduplicationHandler as you mentioned. Using a time-based approach sounds a bit too specific IMO and everyone will have different requirements there. Closing as the close() stuff is already tracked in #197

<!-- gh-comment-id:398031929 --> @Seldaek commented on GitHub (Jun 18, 2018): I think the best solution here would be to call close() on it at the end of every "job" or whatever you are doing on the CLI. Which would flush every time as if it was a web request in a fcgi context. Monolog 2.0 should have close() available on the Logger instance to facilitate this, but in 1.x you can already call close on the DeduplicationHandler as you mentioned. Using a time-based approach sounds a bit too specific IMO and everyone will have different requirements there. Closing as the close() stuff is already tracked in #197
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#449
No description provided.