diff options
Diffstat (limited to 'it.class')
-rw-r--r-- | it.class | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -84,6 +84,7 @@ function timerlog($label = '') * @param named parameter id identifier of error. if given, only subsequent errors of same id will trigger message * @param named parameter graceperiod number of seconds within which additional errors are ignored if id is set * @param named parameter timewindow number of seconds after graceperiod within which the second error must occur if id is set + * @param named parameter backtraceskip number of stack levels to drop */ function error($p = array(), $body = "", $to = "") { @@ -98,7 +99,6 @@ function error($p = array(), $body = "", $to = "") $title = $p; $p = array(); } - $p += array('timewindow' => 25*3600, 'graceperiod' => 60, 'backtraceskip' => 0); if (!$to) @@ -128,6 +128,7 @@ function error($p = array(), $body = "", $to = "") { @mkdir("/tmp/alertdata"); @chmod("/tmp/alertdata", 0777); + @unlink($lastsentfn); touch($lastsentfn); @chmod($lastsentfn, 0666); @@ -139,7 +140,7 @@ function error($p = array(), $body = "", $to = "") if (!function_exists('memory_get_usage') || (memory_get_usage() < 50000000)) $trace = it_debug::backtrace($p['backtraceskip']); - $body .= ($url ? "\nUrl: $url" : "") . ($trace ? "\n\nTrace: " . $trace : ""); + $body .= ($url && !$toscreen? "Url: $url\n" : "") . ($trace ? " Trace: $trace\n" : ""); if (!$toscreen) { @@ -149,12 +150,12 @@ function error($p = array(), $body = "", $to = "") if (($pipe = popen($cmd, "w"))) { $body .= "\n\nLocals" . print_r($p['locals'], true) . "\n\n\$_REQUEST: ".print_r($_REQUEST, true) . "\n\$_SERVER: " . print_r($_SERVER, true) . "\n\nStack:\n" . print_r(debug_backtrace(), true); - fputs($pipe, $body); + fputs($pipe, "$body\n"); pclose($pipe); } } else if ($_SERVER['REMOTE_ADDR']) - echo "<pre>$title\n$body\n</pre>"; + echo "<pre>$title\n$body</pre>"; } error_log("it::error: ".$title . ": " . $trace . (EDC('verbose') ? D($p['locals']) : "")); @@ -166,7 +167,9 @@ function error($p = array(), $body = "", $to = "") */ function fatal($title='', $body='', $to='') { - it::error($title, $body, $to); + $p = is_array($title) ? $title : array('title' => $title, 'body' => $body, 'to' => $to); + $p['backtraceskip']++; + it::error($p); exit(1); } |