Public Member Functions | |
| ilLog ($a_log_path, $a_log_file, $a_tag="", $a_enabled=true, $a_log_level=NULL) | |
| constructor | |
| setLogLevel ($a_log_level) | |
| set global log level | |
| checkLogLevel ($a_log_level) | |
| determine log level | |
| setLogFormat ($a_format) | |
| getLogFormat () | |
| setPath ($a_str) | |
| setFilename ($a_str) | |
| setTag ($a_str) | |
| writeLanguageLog ($a_topic, $a_lang_key) | |
| special language checking routine | |
| writeWarning ($a_message) | |
| special warning message | |
| logError ($a_code, $a_msg) | |
| this function is automatically called by class.ilErrorHandler in case of an error To log manually please use $this::write public | |
| write ($a_msg, $a_log_level=NULL) | |
| logging | |
| delete () | |
| delete logfile | |
Data Fields | |
| $path | |
| $filename | |
| $tag | |
| $log_format | |
| $FATAL | |
| $WARNING | |
| $MESSAGE | |
Definition at line 38 of file class.ilLog.php.
| ilLog::checkLogLevel | ( | $ | a_log_level | ) |
determine log level
private
| integer | log level |
Definition at line 128 of file class.ilLog.php.
Referenced by write().
{
if (empty($a_log_level))
return $this->default_log_level;
$level = (int) $a_log_level;
if ($a_log_level != (int) $a_log_level)
return $this->default_log_level;
return $level;
}
Here is the caller graph for this function:| ilLog::delete | ( | ) |
delete logfile
Definition at line 263 of file class.ilLog.php.
{
if (@is_file($this->path."/".$this->filename))
{
@unlink($this->path."/".$this->filename);
}
}
| ilLog::getLogFormat | ( | ) |
Definition at line 146 of file class.ilLog.php.
Referenced by write().
{
return $this->log_format;
}
Here is the caller graph for this function:| ilLog::ilLog | ( | $ | a_log_path, | |
| $ | a_log_file, | |||
| $ | a_tag = "", |
|||
| $ | a_enabled = true, |
|||
| $ | a_log_level = NULL | |||
| ) |
constructor
set the filename
| string |
Definition at line 81 of file class.ilLog.php.
References setLogFormat(), and setLogLevel().
{
// init vars
$this->FATAL = 10;
$this->WARNING = 20;
$this->MESSAGE = 30;
$this->default_log_level= $this->WARNING;
$this->current_log_level = $this->setLogLevel($a_log_level);
$this->path = ($a_log_path) ? $a_log_path : ILIAS_ABSOLUTE_PATH;
$this->filename = ($a_log_file) ? $a_log_file : "ilias.log";
$this->tag = ($a_tag == "") ? "unknown" : $a_tag;
$this->enabled = (bool) $a_enabled;
$this->setLogFormat(date("[y-m-d H:i:s] ")."[".$this->tag."] ");
}
Here is the call graph for this function:| ilLog::logError | ( | $ | a_code, | |
| $ | a_msg | |||
| ) |
this function is automatically called by class.ilErrorHandler in case of an error To log manually please use $this::write public
| integer | error level code from PEAR_Error | |
| string | error message |
Definition at line 201 of file class.ilLog.php.
References write().
{
switch ($a_code)
{
case "3":
return; // don't log messages
$error_level = "message";
break;
case "2":
$error_level = "warning";
break;
case "1":
$error_level = "fatal";
break;
default:
$error_level = "unknown";
break;
}
$this->write("ERROR (".$error_level."): ".$a_msg);
}
Here is the call graph for this function:| ilLog::setFilename | ( | $ | a_str | ) |
Definition at line 156 of file class.ilLog.php.
{
$this->filename = $a_str;
}
| ilLog::setLogFormat | ( | $ | a_format | ) |
Definition at line 141 of file class.ilLog.php.
Referenced by ilLog().
{
$this->log_format = $a_format;
}
Here is the caller graph for this function:| ilLog::setLogLevel | ( | $ | a_log_level | ) |
set global log level
private
| integer | log level |
Definition at line 106 of file class.ilLog.php.
Referenced by ilLog().
{
switch (strtolower($a_log_level))
{
case "fatal":
return $this->FATAL;
case "warning":
return $this->WARNING;
case "message":
return $this->MESSAGE;
default:
return $this->default_log_level;
}
}
Here is the caller graph for this function:| ilLog::setPath | ( | $ | a_str | ) |
Definition at line 151 of file class.ilLog.php.
{
$this->path = $a_str;
}
| ilLog::setTag | ( | $ | a_str | ) |
Definition at line 161 of file class.ilLog.php.
{
$this->tag = $a_str;
}
| ilLog::write | ( | $ | a_msg, | |
| $ | a_log_level = NULL | |||
| ) |
logging
this method logs anything you want. It appends a line to the given logfile. Datetime and client id is appended automatically You may set the log level in each call. Leave blank to use default log level specified in ilias.ini: [log] level = "<level>" possible values are fatal,warning,message
public
| string | error message | |
| integer | log level (optional) |
Definition at line 240 of file class.ilLog.php.
References checkLogLevel(), and getLogFormat().
Referenced by logError(), writeLanguageLog(), and writeWarning().
{
if ($this->enabled and $this->current_log_level >= $this->checkLogLevel($a_log_level))
{
$fp = @fopen ($this->path."/".$this->filename, "a");
if ($fp == false)
{
die("Logfile: cannot open file. Please give Logfile Writepermissions.");
}
if (fwrite($fp,$this->getLogFormat().$a_msg."\n") == -1)
{
die("Logfile: cannot write to file. Please give Logfile Writepermissions.");
}
fclose($fp);
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| ilLog::writeLanguageLog | ( | $ | a_topic, | |
| $ | a_lang_key | |||
| ) |
special language checking routine
only add a log entry to the logfile if there isn't a log entry for the topic
| string | public |
Definition at line 175 of file class.ilLog.php.
References write().
{
//TODO: go through logfile and search for the topic
//only write the log if the error wasn't reported yet
$this->write("Language (".$a_lang_key."): topic -".$a_topic."- not present",$this->MESSAGE);
}
Here is the call graph for this function:| ilLog::writeWarning | ( | $ | a_message | ) |
special warning message
| string | public |
Definition at line 188 of file class.ilLog.php.
References write().
{
$this->write("WARNING: ".$a_message);
}
Here is the call graph for this function:| ilLog::$FATAL |
Definition at line 56 of file class.ilLog.php.
| ilLog::$filename |
Definition at line 47 of file class.ilLog.php.
| ilLog::$log_format |
Definition at line 49 of file class.ilLog.php.
| ilLog::$MESSAGE |
Definition at line 70 of file class.ilLog.php.
| ilLog::$path |
Definition at line 46 of file class.ilLog.php.
| ilLog::$tag |
Definition at line 48 of file class.ilLog.php.
| ilLog::$WARNING |
Definition at line 63 of file class.ilLog.php.
1.7.1