63 function ilLog($a_log_path, $a_log_file, $a_tag =
"", $a_enabled =
true, $a_log_level = NULL)
71 $this->current_log_level = $this->
setLogLevel($a_log_level);
74 $this->filename = ($a_log_file) ? $a_log_file :
"ilias.log";
75 $this->tag = ($a_tag ==
"") ?
"unknown" : $a_tag;
76 $this->enabled = (bool) $a_enabled;
78 $this->
setLogFormat(@date(
"[y-m-d H:i:s] ").
"[".$this->tag.
"] ");
93 switch (strtolower($a_log_level))
102 return $this->default_log_level;
115 if (empty($a_log_level))
116 return $this->default_log_level;
118 $level = (int) $a_log_level;
120 if ($a_log_level != (
int) $a_log_level)
121 return $this->default_log_level;
128 $this->log_format = $a_format;
138 $this->path = $a_str;
143 $this->filename = $a_str;
164 $this->
write(
"Language (".$a_lang_key.
"): topic -".$a_topic.
"- not present",$this->MESSAGE);
175 $this->
write(
"WARNING: ".$a_message);
192 $error_level =
"message";
196 $error_level =
"warning";
200 $error_level =
"fatal";
204 $error_level =
"unknown";
208 $this->
write(
"ERROR (".$error_level.
"): ".$a_msg);
225 function write($a_msg, $a_log_level = NULL)
227 if ($this->enabled and $this->current_log_level >= $this->
checkLogLevel($a_log_level))
231 if ($this->fp ==
false)
236 if (fwrite($this->fp,$this->
getLogFormat().$a_msg.
"\n") == -1)
243 if ($a_log_level == $this->FATAL)
258 $this->
write($e->getTraceAsString());
268 function dump($a_var, $a_log_level = NULL)
270 $this->
write(print_r($a_var,
true), $a_log_level);
277 $this->fp = @fopen ($this->path.
"/".$this->filename,
"a");
280 if (!$this->fp && $this->enabled)
282 include_once(
"./Services/Logging/exceptions/class.ilLogException.php");
283 throw new ilLogException(
'Unable to open log file for writing. Please check setup path to log file and possible write access.');
299 if (@is_file($this->path.
"/".$this->filename))
301 @unlink($this->path.
"/".$this->filename);