mirror of
https://github.com/Seldaek/monolog.git
synced 2025-10-20 16:16:37 +02:00
Add Logger::close and clarify what close and reset do plus
This commit is contained in:
@@ -354,6 +354,35 @@ class Logger implements LoggerInterface, ResettableInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends a log cycle and frees all resources used by handlers.
|
||||
*
|
||||
* Closing a Handler means flushing all buffers and freeing any open resources/handles.
|
||||
* Handlers that have been closed should be able to accept log records again and re-open
|
||||
* themselves on demand, but this may not always be possible depending on implementation.
|
||||
*
|
||||
* This is useful at the end of a request and will be called automatically on every handler
|
||||
* when they get destructed.
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
foreach ($this->handlers as $handler) {
|
||||
if (method_exists($handler, 'close')) {
|
||||
$handler->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends a log cycle and resets all handlers and processors to their initial state.
|
||||
*
|
||||
* Resetting a Handler or a Processor means flushing/cleaning all buffers, resetting internal
|
||||
* state, and getting it back to a state in which it can receive log records again.
|
||||
*
|
||||
* This is useful in case you want to avoid logs leaking between two requests or jobs when you
|
||||
* have a long running process like a worker or an application server serving multiple requests
|
||||
* in one process.
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
foreach ($this->handlers as $handler) {
|
||||
|
||||
Reference in New Issue
Block a user