add debug stdout logger

This commit is contained in:
Andrew Dolgov 2018-08-15 15:08:31 +03:00
parent c4869cd573
commit 611aeb7197
2 changed files with 37 additions and 1 deletions

View File

@ -49,6 +49,9 @@ class Logger {
case "syslog": case "syslog":
$this->adapter = new Logger_Syslog(); $this->adapter = new Logger_Syslog();
break; break;
case "stdout":
$this->adapter = new Logger_Stdout();
break;
default: default:
$this->adapter = false; $this->adapter = false;
} }

33
classes/logger/stdout.php Normal file
View File

@ -0,0 +1,33 @@
<?php
class Logger_Stdout {
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
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)";
print "[EEE] $priority $errname ($file:$line) $errstr\n";
}
}