logger : add stderr support
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2186 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
18
logger.php
18
logger.php
@@ -141,6 +141,8 @@ class logger
|
|||||||
$logsType = $this->logtype;
|
$logsType = $this->logtype;
|
||||||
if (in_array ("display", $logsType))
|
if (in_array ("display", $logsType))
|
||||||
$this->logdisplay ($msg, $priority);
|
$this->logdisplay ($msg, $priority);
|
||||||
|
if (in_array ("stderr", $logsType))
|
||||||
|
$this->logstderr ($msg, $priority);
|
||||||
if (in_array ("file", $logsType))
|
if (in_array ("file", $logsType))
|
||||||
$this->logfile ($msg, $priority);
|
$this->logfile ($msg, $priority);
|
||||||
if (in_array ("syslog", $logsType))
|
if (in_array ("syslog", $logsType))
|
||||||
@@ -197,6 +199,22 @@ class logger
|
|||||||
echo "\n";
|
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", "<tt>");
|
||||||
|
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", "</tt><br/>");
|
||||||
|
file_put_contents("php://stderr", "\n");
|
||||||
|
}
|
||||||
|
|
||||||
/** Log $message on syslog
|
/** Log $message on syslog
|
||||||
@param string $message Message to log
|
@param string $message Message to log
|
||||||
@param integer|null $priority Priority to use */
|
@param integer|null $priority Priority to use */
|
||||||
|
|||||||
Reference in New Issue
Block a user