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;
151 $this->filename = $a_str;
179 $this->
write(
"Language (".$a_lang_key.
"): topic -".$a_topic.
"- not present",$this->MESSAGE);
190 $this->
write(
"WARNING: ".$a_message);
207 $error_level =
"message";
211 $error_level =
"warning";
215 $error_level =
"fatal";
219 $error_level =
"unknown";
223 $this->
write(
"ERROR (".$error_level.
"): ".$a_msg);
240 function write($a_msg, $a_log_level = NULL)
242 if ($this->enabled and $this->current_log_level >= $this->
checkLogLevel($a_log_level))
246 if ($this->fp ==
false)
251 if (fwrite($this->fp,$this->
getLogFormat().$a_msg.
"\n") == -1)
258 if ($a_log_level == $this->FATAL)
273 $this->
write($e->getTraceAsString());
283 function dump($a_var, $a_log_level = NULL)
285 $this->
write(print_r($a_var,
true), $a_log_level);
296 $this->fp = @fopen ($this->path.
"/".$this->filename,
"a");
299 if (!$this->fp && $this->enabled)
301 include_once(
"./Services/Logging/exceptions/class.ilLogException.php");
302 throw new ilLogException(
'Unable to open log file for writing. Please check setup path to log file and possible write access.');
318 if (@is_file($this->path.
"/".$this->filename))
320 @unlink($this->path.
"/".$this->filename);