mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-01 16:45:02 +02:00
feat: improve logging and error handling (#2994)
* feat: improve logging and error handling * trim absolute path from file name * fix: suppress php errors from xml parsing * fix: respect the error reporting level in the custom error handler * feat: dont log error which is produced by bots * ignore error about invalid bridge name * upgrade bridge exception from warning to error * remove remnants of using phps builin error handler * move responsibility of printing php error from logger to error handler * feat: include url in log record context * fix: always include url in log record contect Also ignore more non-interesting exceptions. * more verbose httpexception * fix * fix
This commit is contained in:
parent
5578a735d9
commit
27b3d7c34e
11 changed files with 135 additions and 80 deletions
|
@ -73,9 +73,6 @@ class Debug
|
|||
);
|
||||
|
||||
if (self::$enabled) {
|
||||
ini_set('display_errors', '1');
|
||||
error_reporting(E_ALL);
|
||||
|
||||
self::$secure = !empty($debug_whitelist);
|
||||
}
|
||||
|
||||
|
@ -99,25 +96,18 @@ class Debug
|
|||
return self::$secure;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a debug message to error_log if debug mode is enabled
|
||||
*
|
||||
* @param string $text The message to add to error_log
|
||||
*/
|
||||
public static function log($text)
|
||||
public static function log($message)
|
||||
{
|
||||
if (!self::isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3);
|
||||
$calling = end($backtrace);
|
||||
$message = $calling['file'] . ':'
|
||||
. $calling['line'] . ' class '
|
||||
. ($calling['class'] ?? '<no-class>') . '->'
|
||||
. $calling['function'] . ' - '
|
||||
. $text;
|
||||
|
||||
error_log($message);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue