]> git.wh0rd.org - tt-rss.git/blob - classes/logger/sql.php
experimental singleton-based Db connection
[tt-rss.git] / classes / logger / sql.php
1 <?php
2 class Logger_SQL {
3
4 function log_error($errno, $errstr, $file, $line, $context) {
5
6 if ($errno == E_NOTICE) return false;
7
8 if (Db::get()) {
9 $errno = Db::get()->escape_string($errno);
10 $errstr = Db::get()->escape_string($errstr);
11 $file = Db::get()->escape_string($file);
12 $line = Db::get()->escape_string($line);
13 $context = ''; // backtrace is a lot of data which is not really critical to store
14 //$context = db_escape_string($this->link, serialize($context));
15
16 $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : "NULL";
17
18 $result = Db::get()->query(
19 "INSERT INTO ttrss_error_log
20 (errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES
21 ($errno, '$errstr', '$file', '$line', '$context', $owner_uid, NOW())");
22
23 return Db::get()->affected_rows($result) != 0;
24
25 }
26 return false;
27 }
28
29 }
30 ?>