Refactor exception handling in FileLogging

This commit is contained in:
netkas 2024-10-30 00:14:33 -04:00
parent 9fdedc5dea
commit 9435841987
2 changed files with 9 additions and 12 deletions

View file

@ -29,32 +29,25 @@ class FileLogging implements LogHandlerInterface
if(Validate::checkLevelType(LogLevel::DEBUG, $application->getConsoleLoggingLevel()))
{
$backtrace_output = Utilities::getTraceString($event, false);
$output = sprintf("[%s] [%s] [%s] %s %s" . PHP_EOL,
self::getTimestamp(), $application->getApplicationName(), $event->getLevel()->name, $backtrace_output, $event->getMessage()
);
if($event->getException() !== null)
{
$output .= self::outException($event->getException());
}
}
else if(Validate::checkLevelType(LogLevel::VERBOSE, $application->getConsoleLoggingLevel()))
{
$backtrace_output = Utilities::getTraceString($event, false);
$output = sprintf("[%s] [%s] [%s] %s %s" . PHP_EOL, self::getTimestamp(), $application->getApplicationName(), $event->getLevel()->name, $backtrace_output, $event->getMessage());
if($event->getException() !== null)
{
$output .= self::outException($event->getException());
}
}
else
{
$output = sprintf("[%s] [%s] [%s] %s" . PHP_EOL, self::getTimestamp(), $application->getApplicationName(), $event->getLevel()->name, $event->getMessage());
}
if($event->getException() !== null)
{
$output .= self::outException($event->getException());
}
self::getLogger($application)->append($output);
}