summaryrefslogtreecommitdiff
path: root/classes/logger/sql.php
blob: c45841600e623061115b96b39142c23e86739d06 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
class Logger_SQL {

	function log_error($errno, $errstr, $file, $line, $context) {

		if ($errno == E_NOTICE) return false;

		if (Db::get()) {
			$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 = db_escape_string($this->link, 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;
	}

}
?>