64 function ilLog($a_log_path, $a_log_file, $a_tag =
"", $a_enabled =
true, $a_log_level = NULL)
72 $this->current_log_level = $this->
setLogLevel($a_log_level);
75 $this->filename = ($a_log_file) ? $a_log_file :
"ilias.log";
76 $this->tag = ($a_tag ==
"") ?
"unknown" : $a_tag;
77 $this->enabled = (bool) $a_enabled;
79 $this->
setLogFormat(@date(
"[y-m-d H:i:s] ").
"[".$this->tag.
"] ");
94 switch (strtolower($a_log_level))
103 return $this->default_log_level;
116 if (empty($a_log_level))
117 return $this->default_log_level;
119 $level = (int) $a_log_level;
121 if ($a_log_level != (
int) $a_log_level)
122 return $this->default_log_level;
129 $this->log_format = $a_format;
139 $this->path = $a_str;
144 $this->filename = $a_str;
172 $this->
write(
"Language (".$a_lang_key.
"): topic -".$a_topic.
"- not present",$this->MESSAGE);
183 $this->
write(
"WARNING: ".$a_message);
200 $error_level =
"message";
204 $error_level =
"warning";
208 $error_level =
"fatal";
212 $error_level =
"unknown";
216 $this->
write(
"ERROR (".$error_level.
"): ".$a_msg);
233 function write($a_msg, $a_log_level = NULL)
235 if ($this->enabled and $this->current_log_level >= $this->
checkLogLevel($a_log_level))
239 if ($this->fp ==
false)
244 if (fwrite($this->fp,$this->
getLogFormat().$a_msg.
"\n") == -1)
251 if ($a_log_level == $this->FATAL)
266 $this->
write($e->getTraceAsString());
276 function dump($a_var, $a_log_level = NULL)
278 $this->
write(print_r($a_var,
true), $a_log_level);
289 $this->fp = @fopen ($this->path.
"/".$this->filename,
"a");
292 if (!$this->fp && $this->enabled)
294 include_once(
"./Services/Logging/exceptions/class.ilLogException.php");
295 throw new ilLogException(
'Unable to open log file for writing. Please check setup path to log file and possible write access.');
311 if (@is_file($this->path.
"/".$this->filename))
313 @unlink($this->path.
"/".$this->filename);