mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-16 13:34:11 +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:
@@ -35,6 +35,9 @@ class DisplayAction implements ActionInterface
|
||||
throw new \Exception('This bridge is not whitelisted');
|
||||
}
|
||||
|
||||
$formatFactory = new FormatFactory();
|
||||
$format = $formatFactory->create($format);
|
||||
|
||||
$bridge = $bridgeFactory->create($bridgeClassName);
|
||||
$bridge->loadConfiguration();
|
||||
|
||||
@@ -150,8 +153,7 @@ class DisplayAction implements ActionInterface
|
||||
'icon' => $bridge->getIcon()
|
||||
];
|
||||
} catch (\Throwable $e) {
|
||||
error_log($e);
|
||||
|
||||
Logger::error(sprintf('Exception in %s', $bridgeClassName), ['e' => $e]);
|
||||
$errorCount = logBridgeError($bridge::NAME, $e->getCode());
|
||||
|
||||
if ($errorCount >= Configuration::getConfig('error', 'report_limit')) {
|
||||
@@ -163,23 +165,10 @@ class DisplayAction implements ActionInterface
|
||||
|
||||
$message = sprintf('Bridge returned error %s! (%s)', $e->getCode(), $request['_error_time']);
|
||||
$item->setTitle($message);
|
||||
|
||||
$item->setURI(
|
||||
(isset($_SERVER['REQUEST_URI']) ? parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) : '')
|
||||
. '?'
|
||||
. http_build_query($request)
|
||||
);
|
||||
|
||||
$item->setURI(get_current_url());
|
||||
$item->setTimestamp(time());
|
||||
|
||||
$message = sprintf(
|
||||
'Uncaught Exception %s: %s at %s line %s',
|
||||
get_class($e),
|
||||
$e->getMessage(),
|
||||
trim_path_prefix($e->getFile()),
|
||||
$e->getLine()
|
||||
);
|
||||
|
||||
$message = create_sane_exception_message($e);
|
||||
$content = render_template('bridge-error.html.php', [
|
||||
'message' => $message,
|
||||
'stacktrace' => create_sane_stacktrace($e),
|
||||
@@ -204,8 +193,6 @@ class DisplayAction implements ActionInterface
|
||||
]);
|
||||
}
|
||||
|
||||
$formatFactory = new FormatFactory();
|
||||
$format = $formatFactory->create($format);
|
||||
$format->setItems($items);
|
||||
$format->setExtraInfos($infos);
|
||||
$lastModified = $cache->getTime();
|
||||
|
Reference in New Issue
Block a user