summaryrefslogtreecommitdiff
path: root/classes/logger
diff options
context:
space:
mode:
Diffstat (limited to 'classes/logger')
-rw-r--r--classes/logger/sql.php28
-rw-r--r--classes/logger/syslog.php31
2 files changed, 59 insertions, 0 deletions
diff --git a/classes/logger/sql.php b/classes/logger/sql.php
new file mode 100644
index 000000000..c0f8b4598
--- /dev/null
+++ b/classes/logger/sql.php
@@ -0,0 +1,28 @@
+<?php
+class Logger_SQL {
+
+ function log_error($errno, $errstr, $file, $line, $context) {
+ if (Db::get() && get_schema_version() > 117) {
+
+ $errno = Db::get()->escape_string($errno);
+ $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));
+
+ $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : "NULL";
+
+ $result = Db::get()->query(
+ "INSERT INTO ttrss_error_log
+ (errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES
+ ($errno, '$errstr', '$file', '$line', '$context', $owner_uid, NOW())");
+
+ return Db::get()->affected_rows($result) != 0;
+ }
+
+ return false;
+ }
+
+}
+?>
diff --git a/classes/logger/syslog.php b/classes/logger/syslog.php
new file mode 100644
index 000000000..b8b5260a0
--- /dev/null
+++ b/classes/logger/syslog.php
@@ -0,0 +1,31 @@
+<?php
+class Logger_Syslog {
+
+ function log_error($errno, $errstr, $file, $line, $context) {
+
+ switch ($errno) {
+ case E_ERROR:
+ case E_PARSE:
+ case E_CORE_ERROR:
+ case E_COMPILE_ERROR:
+ case E_USER_ERROR:
+ $priority = LOG_ERR;
+ break;
+ case E_WARNING:
+ case E_CORE_WARNING:
+ case E_COMPILE_WARNING:
+ case E_USER_WARNING:
+ $priority = LOG_WARNING;
+ break;
+ default:
+ $priority = LOG_INFO;
+ }
+
+ $errname = Logger::$errornames[$errno] . " ($errno)";
+
+ syslog($priority, "[tt-rss] $errname ($file:$line) $errstr");
+
+ }
+
+}
+?>