/**
* If deferred, write all pending logs.
*
* @since 3.9.0
*/
public function __destruct()
{
// Nothing to do
if (!$this->defer || empty($this->deferredEntries)) {
return;
}
// Initialise the file if not already done.
$this->initFile();
// Format all lines and write to file.
$lines = array_map(array($this, 'formatLine'), $this->deferredEntries);
if (!File::append($this->path, implode("\n", $lines) . "\n")) {
throw new \RuntimeException('Cannot write to log file.');
}
}