From 01159fa6f8c2421457297914dd42039bc12b826e Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 3 May 2025 08:18:16 +0300 Subject: error handler - dump caught exception/fatal error to debug log if running under CLI SAPI --- include/errorhandler.php | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/errorhandler.php') diff --git a/include/errorhandler.php b/include/errorhandler.php index c155c9989..2b6d51a7d 100644 --- a/include/errorhandler.php +++ b/include/errorhandler.php @@ -49,6 +49,11 @@ function ttrss_error_handler(int $errno, string $errstr, string $file, int $line $context = format_backtrace(debug_backtrace()); $errstr = truncate_middle($errstr, 16384, " (...) "); + if (php_sapi_name() == 'cli' && class_exists("Debug")) { + Debug::log("!! Exception: $errstr ($file:$line)"); + Debug::log($context); + } + if (class_exists("Logger")) return Logger::log_error((int)$errno, $errstr, $file, (int)$line, $context); else @@ -70,6 +75,11 @@ function ttrss_fatal_handler(): bool { $file = substr(str_replace(dirname(__DIR__), "", $file), 1); + if (php_sapi_name() == 'cli' && class_exists("Debug")) { + Debug::log("!! Fatal error: $errstr ($file:$line)"); + Debug::log($context); + } + if (class_exists("Logger")) return Logger::log_error((int)$errno, $errstr, $file, (int)$line, $context); } -- cgit v1.2.3-54-g00ecf