summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2007-09-30 19:08:06 +0000
committerUrban Müller2007-09-30 19:08:06 +0000
commit899175eb02f1160dcdeb3f79abeb7e6a36e1e9ac (patch)
tree654104749145107bd936ae7d543578fe0531ade5
parent12b423d8e2ced2fef658048aae755bb7b3094d88 (diff)
downloaditools-899175eb02f1160dcdeb3f79abeb7e6a36e1e9ac.tar.gz
itools-899175eb02f1160dcdeb3f79abeb7e6a36e1e9ac.tar.bz2
itools-899175eb02f1160dcdeb3f79abeb7e6a36e1e9ac.zip
improved error format
-rw-r--r--it.class13
1 files changed, 8 insertions, 5 deletions
diff --git a/it.class b/it.class
index 837e33c..0092e86 100644
--- a/it.class
+++ b/it.class
@@ -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);
}