From: Andrew Dolgov Date: Fri, 4 Dec 2015 12:58:20 +0000 (+0300) Subject: store formatted backtrace to sql log X-Git-Tag: 16.3~76 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=b8619f8db01c10500814171631c83da3f770ea03;p=tt-rss.git store formatted backtrace to sql log --- diff --git a/classes/logger/sql.php b/classes/logger/sql.php index c0f8b459..96263a97 100644 --- a/classes/logger/sql.php +++ b/classes/logger/sql.php @@ -8,8 +8,7 @@ class Logger_SQL { $errstr = Db::get()->escape_string($errstr); $file = Db::get()->escape_string($file); $line = Db::get()->escape_string($line); - $context = ''; // backtrace is a lot of data which is not really critical to store - //$context = $this->dbh->escape_string(serialize($context)); + $context = DB::get()->escape_string($context); $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : "NULL"; diff --git a/classes/pref/system.php b/classes/pref/system.php index 7accb1f9..6586d6c6 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -31,7 +31,7 @@ class Pref_System extends Handler_Protected { if (LOG_DESTINATION == "sql") { $result = $this->dbh->query("SELECT errno, errstr, filename, lineno, - created_at, login FROM ttrss_error_log + created_at, login, context FROM ttrss_error_log LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id) ORDER BY ttrss_error_log.id DESC LIMIT 100"); @@ -61,7 +61,7 @@ class Pref_System extends Handler_Protected { print "" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")"; print "" . $line["filename"] . ":" . $line["lineno"] . ""; - print "" . $line["errstr"] . ""; + print "" . $line["errstr"] . "
" . nl2br($line["context"]) . ""; print "" . $line["login"] . ""; print "" . diff --git a/include/errorhandler.php b/include/errorhandler.php index 21cc9a94..8189feaf 100644 --- a/include/errorhandler.php +++ b/include/errorhandler.php @@ -1,4 +1,36 @@ log_error($errno, $errstr, $file, $line, $context); @@ -27,7 +60,7 @@ function ttrss_fatal_handler() { if (!$errno) return false; - $context = debug_backtrace(); + $context = format_backtrace(debug_backtrace()); $file = substr(str_replace(dirname(dirname(__FILE__)), "", $file), 1);