40 $this->
error(
"Can't access $logfile, using syslog");
50 function debug($string, $args = NULL)
52 $this->
wlog(
"D", $string);
56 $this->
wlog(
"C", $string);
58 function info($string, $args = NULL)
60 $this->
wlog(
"I", $string);
64 $this->
wlog(
"W", $string);
66 function error($string, $args = NULL)
68 $this->
wlog(
"E", $string);
70 function fatal($string, $args = NULL)
72 $this->
wlog(
"F", $string);
76 $this->
wlog(
"O", $string);
81 $deb = gettimeofday();
82 $this->deb =
$deb[
"sec"] +
$deb[
"usec"] / 1000000;
90 $tic = gettimeofday();
91 $now = $tic[
"sec"] + $tic[
"usec"] / 1000000;
92 $duree = round($now - $this->
tic, 3);
93 $this->
info(
"CHRONO-INT [$this->ptext]/[$text] : $duree");
99 $fin = gettimeofday();
100 $this->fin = $fin[
"sec"] + $fin[
"usec"] / 1000000;
101 $duree = round($this->fin - $this->deb, 3);
102 $this->
info(
"CHRONO [$this->ptext]/[$text] : $duree");
108 if (isset($CORE_LOGLEVEL) && is_int(strpos($CORE_LOGLEVEL,
"C"))) {
109 global $call_ind, $call_stack, $call_pre, $call_reqid;
110 if (!isset($call_ind)) $call_ind = 0;
111 if (!isset($call_pre)) $call_pre =
"-";
112 if (!isset($call_reqid)) $call_reqid = rand(1, 100);
113 $this->
callstack(
"($call_reqid) $call_pre : entering $string");
114 $call_stack[$call_ind] = $string;
116 $call_pre = $call_pre .
"-";
123 if (isset($CORE_LOGLEVEL) && is_int(strpos($CORE_LOGLEVEL,
"C"))) {
124 global $call_ind, $call_stack, $call_pre, $call_reqid;
125 $call_pre = substr($call_pre, 0, strlen($call_pre) - 1);
127 $this->
callstack(
"($call_reqid) $call_pre : exiting {$call_stack[$call_ind]}");
131 function wlog($sta, $str, $args = NULL, $facility = LOG_LOCAL6)
138 if (is_array($str)) $str = implode(
", ", $str);
139 if ($sta ==
"S" || (isset($CORE_LOGLEVEL) && is_int(strpos($CORE_LOGLEVEL, $sta)))) {
140 $addr = $_SERVER[
"REMOTE_ADDR"];
141 $appf =
"[{$sta}] Dynacase";
143 $appf.= ($this->
function !=
"" ?
":" . $this->
function :
"");
144 $str =
' ' . $this->loghead .
': ' . $str;
145 if (!$this->usesyslog) {
146 $xx = date(
"d/m/Y H:i:s", time()) .
" {$appf} [{$addr}] ";
147 $xx = $xx . $str .
"\n";
148 $fd = fopen($this->logfile,
"a");
158 $td = @debug_backtrace(
false);
159 $str.= sprintf(
"%s called in %s%s%s(), file %s:%s", $td[3][
"function"], $td[4][
"class"], $td[4][
"class"] ?
'::' :
'', $td[4][
"function"], $td[4][
"file"], $td[4][
"line"]);
179 if ($_SERVER[
'HTTP_HOST'] ==
"") {
180 error_log(sprintf(
"%s LOG::$appf %s", date(
"d/m/Y H:i:s", time()) , $str));
182 openlog(
"{$appf}", 0, $facility);
183 syslog($pri,
"[{$addr}] " . $str);