logger : allow to store the logs in session (to be readable in debug)
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@2255 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
17
logger.php
17
logger.php
@@ -17,7 +17,7 @@ class logger
|
||||
$d->logwrite ("Super log NOTICE", $d::NOTICE); */
|
||||
// TODO : Add SQL support
|
||||
/** The method to log.
|
||||
Can be display, file, syslog, stderr
|
||||
Can be display, file, syslog, stderr, session
|
||||
Can be merged with a pipe : "display|syslog|file" or put in array */
|
||||
public $logtype = "stderr";
|
||||
/** For logtype=file, the filename to use */
|
||||
@@ -193,6 +193,8 @@ class logger
|
||||
$this->logfile ($msg, $priority);
|
||||
if (in_array ("syslog", $logsType))
|
||||
$this->logsyslog ($msg, $priority);
|
||||
if (in_array ("session", $logsType))
|
||||
$this->logsession ($msg, $priority);
|
||||
}
|
||||
|
||||
/** Log $message on file
|
||||
@@ -291,4 +293,17 @@ class logger
|
||||
openlog ($this->syslogPrefix, NULL, $this->syslogFacility);
|
||||
syslog ($priority, $message);
|
||||
}
|
||||
|
||||
/** Log $message on session (for debug)
|
||||
@param string $message Message to log
|
||||
@param integer|null $priority Priority to use */
|
||||
private function logsession ($message, $priority)
|
||||
{
|
||||
if (! isset ($_SESSION))
|
||||
throw new Exception ("No session available to store the log", 500);
|
||||
ini_set ("date.timezone", $this->timezone);
|
||||
$message = date ("Y/m/d H:i:s")." [".$this->priorities[$priority]."] ".
|
||||
$message;
|
||||
$_SESSION["domframework"]["logger"][] = $message;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user