Refactor exception handling in FileLogging
This commit is contained in:
parent
9fdedc5dea
commit
9435841987
2 changed files with 9 additions and 12 deletions
|
@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
This update introduces minor improvements
|
||||
|
||||
### Changed
|
||||
- Refactored exception handling in FileLogging where it will always attempt to print the exception no matter
|
||||
the log level for as long as the log level isn't silent
|
||||
|
||||
|
||||
## [2.0.1] - 2024-10-29
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue