public function dispatch($messages, $final)
{
$targetErrors = [];
foreach ($this->targets as $target) {
if ($target->enabled) {
try {
$target->collect($messages, $final);
} catch (\Exception $e) {
$target->enabled = false;
$targetErrors[] = ['Unable to send log via ' . get_class($target) . ': ' . ErrorHandler::convertExceptionToString($e), Logger::LEVEL_WARNING, __METHOD__, microtime(true), []];
}
}
}
if (!empty($targetErrors)) {
$this->dispatch($targetErrors, true);
}
}