1
0
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:
Dag
2022-10-16 17:55:43 +02:00
committed by GitHub
parent e21394d2d3
commit ffbc107687
13 changed files with 143 additions and 93 deletions

View File

@@ -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);
}
}