diff --git a/logger.php b/logger.php
index cb36821..4a53181 100644
--- a/logger.php
+++ b/logger.php
@@ -141,6 +141,8 @@ class logger
$logsType = $this->logtype;
if (in_array ("display", $logsType))
$this->logdisplay ($msg, $priority);
+ if (in_array ("stderr", $logsType))
+ $this->logstderr ($msg, $priority);
if (in_array ("file", $logsType))
$this->logfile ($msg, $priority);
if (in_array ("syslog", $logsType))
@@ -197,6 +199,22 @@ class logger
echo "\n";
}
+ /** Log $message on stderr with adding date. Add the HTML flags if not in CLI.
+ @param string $message Message to log
+ @param integer|null $priority Priority to use */
+ private function logstderr ($message, $priority)
+ {
+ if (php_sapi_name () !== "cli")
+ file_put_contents("php://stderr", "");
+ ini_set ("date.timezone", $this->timezone);
+ $message = date ("Y/m/d H:i:s")." [".$this->priorities[$priority]."] ".
+ $message;
+ file_put_contents("php://stderr", "$message");
+ if (php_sapi_name () !== "cli")
+ file_put_contents("php://stderr", "
");
+ file_put_contents("php://stderr", "\n");
+ }
+
/** Log $message on syslog
@param string $message Message to log
@param integer|null $priority Priority to use */