mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2026-02-10 16:01:33 +00:00
experimental SQL-based error logger
This commit is contained in:
50
include/errorhandler.php
Normal file
50
include/errorhandler.php
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// TODO: make configurable
|
||||
require_once "classes/logger.php";
|
||||
require_once "classes/logger/sql.php";
|
||||
|
||||
function ttrss_error_handler($errno, $errstr, $file, $line, $context) {
|
||||
global $logger;
|
||||
|
||||
if (!$logger) $logger = new Logger_SQL();
|
||||
|
||||
$errfile = str_replace(dirname(dirname(__FILE__)), "", $errfile);
|
||||
|
||||
if ($logger) {
|
||||
return $logger->log_error($errno, $errstr, $file, $line, $context);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function ttrss_fatal_handler() {
|
||||
global $logger;
|
||||
|
||||
$file = "UNKNOWN FILE";
|
||||
$errstr = "UNKNOWN";
|
||||
$errno = E_CORE_ERROR;
|
||||
$line = -1;
|
||||
|
||||
$error = error_get_last();
|
||||
|
||||
if ($error !== NULL) {
|
||||
$errno = $error["type"];
|
||||
$file = $error["file"];
|
||||
$line = $error["line"];
|
||||
$errstr = $error["message"];
|
||||
|
||||
$context = debug_backtrace();
|
||||
|
||||
$file = str_replace(dirname(dirname(__FILE__)) . "/", "", $file);
|
||||
|
||||
if (!$logger) $logger = new Logger_SQL();
|
||||
|
||||
if ($logger) {
|
||||
$logger->log_error($errno, $errstr, $file, $line, $context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
register_shutdown_function('ttrss_fatal_handler');
|
||||
set_error_handler('ttrss_error_handler');
|
||||
?>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
define('EXPECTED_CONFIG_VERSION', 26);
|
||||
define('SCHEMA_VERSION', 117);
|
||||
define('SCHEMA_VERSION', 118);
|
||||
|
||||
define('LABEL_BASE_INDEX', -1024);
|
||||
define('PLUGIN_FEED_BASE_INDEX', -128);
|
||||
@@ -3369,9 +3369,8 @@
|
||||
return is_file(ICONS_DIR . "/$id.ico") && filesize(ICONS_DIR . "/$id.ico") > 0;
|
||||
}
|
||||
|
||||
function init_connection($link) {
|
||||
function init_connection_only($link) {
|
||||
if ($link) {
|
||||
|
||||
if (DB_TYPE == "pgsql") {
|
||||
pg_query($link, "set client_encoding = 'UTF-8'");
|
||||
pg_set_client_encoding("UNICODE");
|
||||
@@ -3385,6 +3384,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function init_connection($link) {
|
||||
if ($link) {
|
||||
init_connection_only($link);
|
||||
|
||||
global $pluginhost;
|
||||
|
||||
$pluginhost = new PluginHost($link);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
require_once "config.php";
|
||||
require_once "db.php";
|
||||
require_once "errorhandler.php";
|
||||
require_once "lib/accept-to-gettext.php";
|
||||
require_once "lib/gettext/gettext.inc";
|
||||
require_once "version.php";
|
||||
|
||||
Reference in New Issue
Block a user