From b367c951b990b38677e67f1a1756cd4d1eaee50b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Apr 2013 09:45:43 +0400 Subject: make logging configurable; add logging to syslog --- classes/pref/system.php | 75 +++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 34 deletions(-) (limited to 'classes/pref') diff --git a/classes/pref/system.php b/classes/pref/system.php index 725c337dc..d2b6cd746 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -24,46 +24,53 @@ class Pref_System extends Handler_Protected { print "
"; print "
"; - $result = $this->dbh->query("SELECT errno, errstr, filename, lineno, - created_at, login FROM ttrss_error_log - LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id) - ORDER BY ttrss_error_log.id DESC - LIMIT 100"); - - print " "; - - print "

"; - - print " - - - - - - "; - - while ($line = $this->dbh->fetch_assoc($result)) { - print ""; - - foreach ($line as $k => $v) { - $line[$k] = htmlspecialchars($v); + if (LOG_DESTINATION == "sql") { + + $result = $this->dbh->query("SELECT errno, errstr, filename, lineno, + created_at, login FROM ttrss_error_log + LEFT JOIN ttrss_users ON (owner_uid = ttrss_users.id) + ORDER BY ttrss_error_log.id DESC + LIMIT 100"); + + print " "; + + print "

".__("Error")."".__("Filename")."".__("Message")."".__("User")."".__("Date")."
"; + + print " + + + + + + "; + + while ($line = $this->dbh->fetch_assoc($result)) { + print ""; + + foreach ($line as $k => $v) { + $line[$k] = htmlspecialchars($v); + } + + print ""; + print ""; + print ""; + print ""; + + print ""; + + print ""; } - print ""; - print ""; - print ""; - print ""; + print "
".__("Error")."".__("Filename")."".__("Message")."".__("User")."".__("Date")."
" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")" . $line["filename"] . ":" . $line["lineno"] . "" . $line["errstr"] . "" . + make_local_datetime( + $line["created_at"], false) . "
" . Logger::$errornames[$line["errno"]] . " (" . $line["errno"] . ")" . $line["filename"] . ":" . $line["lineno"] . "" . $line["errstr"] . "
"; + } else { - print "" . - make_local_datetime( - $line["created_at"], false) . ""; + print_notice("Please set LOG_DESTINATION to 'sql' in config.php to enable database logging."); - print ""; } - print ""; - print "

"; PluginHost::getInstance()->run_hooks(PluginHost::HOOK_PREFS_TAB, -- cgit v1.2.3