]> git.wh0rd.org - tt-rss.git/blob - classes/logger/sql.php
implement error log viewer
[tt-rss.git] / classes / logger / sql.php
1 <?php
2 class Logger_SQL {
3
4 private $link;
5
6 function __construct() {
7 $this->link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
8 }
9
10 function log_error($errno, $errstr, $file, $line, $context) {
11
12 if ($errno == E_NOTICE) return false;
13
14 if ($this->link) {
15 $errno = db_escape_string($this->link, $errno);
16 $errstr = db_escape_string($this->link, $errstr);
17 $file = db_escape_string($this->link, $file);
18 $line = db_escape_string($this->link, $line);
19 $context = ''; // backtrace is a lot of data which is not really critical to store
20 //$context = db_escape_string($this->link, serialize($context));
21
22 $owner_uid = $_SESSION["uid"] ? $_SESSION["uid"] : "NULL";
23
24 $result = db_query($this->link,
25 "INSERT INTO ttrss_error_log
26 (errno, errstr, filename, lineno, context, owner_uid, created_at) VALUES
27 ($errno, '$errstr', '$file', '$line', '$context', $owner_uid, NOW())");
28
29 return db_affected_rows($this->link, $result) != 0;
30
31 }
32 return false;
33 }
34
35 }
36 ?>