1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-10-21 00:26:10 +02:00

Merge branch '1.x', clean up close/reset for 2.0, refs #997

This commit is contained in:
Jordi Boggiano
2018-11-04 22:41:52 +01:00
13 changed files with 125 additions and 30 deletions

View File

@@ -333,6 +333,33 @@ 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) {
$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) {