]> git.wh0rd.org Git - tt-rss.git/commitdiff
add debug stdout logger
authorAndrew Dolgov <noreply@fakecake.org>
Wed, 15 Aug 2018 12:08:31 +0000 (15:08 +0300)
committerAndrew Dolgov <noreply@fakecake.org>
Wed, 15 Aug 2018 12:08:31 +0000 (15:08 +0300)
classes/logger.php
classes/logger/stdout.php [new file with mode: 0644]

index 0c486e58b4d208fab3c2b53e83f0590f9bf6d884..3b178ae540e8680f99bb585170d8f2bda6be5b45 100644 (file)
@@ -49,6 +49,9 @@ class Logger {
                case "syslog":
                        $this->adapter = new Logger_Syslog();
                        break;
+               case "stdout":
+                       $this->adapter = new Logger_Stdout();
+                       break;
                default:
                        $this->adapter = false;
                }
@@ -61,4 +64,4 @@ class Logger {
                return self::$instance;
        }
 
-}
\ No newline at end of file
+}
diff --git a/classes/logger/stdout.php b/classes/logger/stdout.php
new file mode 100644 (file)
index 0000000..856b2d0
--- /dev/null
@@ -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";
+
+       }
+
+}