summaryrefslogtreecommitdiff
path: root/classes/Logger_Syslog.php
blob: 568398ee0901c2cd856763acb3d30fc6ad1ee469 (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
31
<?php
class Logger_Syslog implements Logger_Adapter {

	function log_error(int $errno, string $errstr, string $file, int $line, string $context): bool {

		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::ERROR_NAMES[$errno] . " ($errno)";

		syslog($priority, "[tt-rss] $errname ($file:$line) $errstr");

		return true;
	}

}