Add more comments to logger.php

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@1961 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2015-01-29 13:08:15 +00:00
parent 62b2878476
commit b62686a098

View File

@@ -51,22 +51,60 @@ class logger
LOG_DEBUG => "DEBUG");
/** Store a new message log in the log manager defined by $logtype
@param string $message Message to log
@param integer|null $priority Priority to use */
public function log ($message, $priority=LOG_NOTICE)
The message can be multiple types. An array will be stored in textual form
but it will accept only one depth.
@param integer|null $priority Priority to use
@param mixed ...$message Message to log */
public function log ($priority=LOG_NOTICE, ...$message)
{
if ($this->loglevelmin < $priority)
return;
$backtrace = debug_backtrace();
$back = reset ($backtrace);
$message .= " [".basename ($back["file"]).":".$back["line"]."]";
$msg = "";
if (isset ($_SERVER["REMOTE_ADDR"]))
{
$msg .= "[".$_SERVER["REMOTE_ADDR"]."] ";
}
// Convert each part of message to text
foreach ($message as $m)
{
if (is_array ($m))
{
$msg .= "[";
foreach ($m as $key=>$val)
{
if (is_array ($val))
{
foreach ($val as $key2=>$val2)
{
$msg .= "$key2=>$val2,";
}
}
else
{
$msg .= "$key=>$val,";
}
}
$msg .= "]";
}
else
{
$msg .= $m;
}
}
// Add the filename which generate the error
$msg .= " [".basename ($back["file"]).":".$back["line"]."]";
$logsType = explode ("|", $this->logtype);
if (in_array ("display", $logsType))
$this->logdisplay ($message, $priority);
$this->logdisplay ($msg, $priority);
if (in_array ("file", $logsType))
$this->logfile ($message, $priority);
$this->logfile ($msg, $priority);
if (in_array ("syslog", $logsType))
$this->logsyslog ($message, $priority);
$this->logsyslog ($msg, $priority);
}
/** Log $message on file