mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-07-31 05:40:24 +02:00
Improve logging and error handling (#3059)
* refactor: logging and errror handling
This commit is contained in:
@@ -101,13 +101,12 @@ class Debug
|
||||
if (!self::isEnabled()) {
|
||||
return;
|
||||
}
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
|
||||
$lastFrame = end($backtrace);
|
||||
$file = trim_path_prefix($lastFrame['file']);
|
||||
$line = $lastFrame['line'];
|
||||
$class = $lastFrame['class'] ?? '';
|
||||
$function = $lastFrame['function'];
|
||||
$text = sprintf('%s:%s %s->%s() %s', $file, $line, $class, $function, $message);
|
||||
Logger::info($text);
|
||||
$e = new \Exception();
|
||||
$trace = trace_from_exception($e);
|
||||
// Drop the current frame
|
||||
array_pop($trace);
|
||||
$lastFrame = $trace[array_key_last($trace)];
|
||||
$text = sprintf('%s(%s): %s', $lastFrame['file'], $lastFrame['line'], $message);
|
||||
Logger::debug($text);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user