summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
authorChristian Schneider2009-09-16 13:45:18 +0000
committerChristian Schneider2009-09-16 13:45:18 +0000
commit1faefabd44ac19968a1c16417e5197bb60b0dce5 (patch)
tree12dcf3e43ab2ee6f8ccaf2c675ecf1db7ea24a88 /it.class
parent83ff56781000923c6dddecf52e2669896411a8d2 (diff)
downloaditools-1faefabd44ac19968a1c16417e5197bb60b0dce5.tar.gz
itools-1faefabd44ac19968a1c16417e5197bb60b0dce5.tar.bz2
itools-1faefabd44ac19968a1c16417e5197bb60b0dce5.zip
Added parameters blockmailid and omitdebuginfo to it::error()
Diffstat (limited to 'it.class')
-rw-r--r--it.class46
1 files changed, 27 insertions, 19 deletions
diff --git a/it.class b/it.class
index 440d889..1ce92de 100644
--- a/it.class
+++ b/it.class
@@ -124,6 +124,8 @@ function timerlog($label = '')
* @param $p['timewindow'] number of seconds after graceperiod within which the second error must occur if id is set
* @param $p['backtraceskip'] number of stack levels to drop
* @param $p['blockmail'] number of seconds to block mails after having sent a mail [3600]
+ * @param $p['blockmailid'] block mail for $p['blockmail'] seconds with same id. Default: $p['to']
+ * @param $p['omitdebuginfo'] Do not add stack dump, locals and environment to output [false]
*/
function error($p = array(), $body = null, $to = null) # $body and $to deprecated
{
@@ -145,7 +147,9 @@ function error($p = array(), $body = null, $to = null) # $body and $to deprecate
'timewindow' => 25*3600,
'backtraceskip' => 0,
'blockmail' => 3600,
+ 'omitdebuginfo' => false,
);
+ $p += array('blockmailid' => md5($p['to']));
@mkdir("/tmp/alertdata");
@chmod("/tmp/alertdata", 0777);
@@ -173,7 +177,7 @@ function error($p = array(), $body = null, $to = null) # $body and $to deprecate
if ($sendmail)
{
- $lastsentfn = "/tmp/alertdata/lastsent_" . getmyuid() . "." . md5($p['to']);
+ $lastsentfn = "/tmp/alertdata/lastsent_" . getmyuid() . "." . $p['blockmailid'];
$now = time();
clearstatcache();
$lastsenttime = @filemtime($lastsentfn);
@@ -195,24 +199,28 @@ function error($p = array(), $body = null, $to = null) # $body and $to deprecate
if ($sendmail) # we're mailing: send maximum info
{
$p['title'] = "Alert: " . $p['title'] . " (on " . getenv('HOSTNAME') . ")";
- unset ($p['locals']['GLOBALS'], $p['locals']['_GET'], $p['locals']['_POST'], $p['locals']['_COOKIE']);
- $locals = print_r($p['locals'], true);
-
- if ($trace && ($fulltrace = array_slice(debug_backtrace(), $p['backtraceskip'])))
- while (strlen(print_r($fulltrace, true)) > 100000)
- array_pop($fulltrace);
-
- $body .= "Host: " . getenv('HOSTNAME') . "\n\n";
- $body .= $p['locals'] && strlen($locals) < 100000 ? "Locals: $locals\n\n" : "";
- $body .= $p['id'] ? "Filter: graceperiod={$p['graceperiod']} timewindow={$p['timewindow']}\n\n" : "";
- $body .= "Time: " . it::date() . "\n\n";
- $body .= $lastsentdebug;
- $body .= $_GET ? "\$_GET: " . print_r($_GET, true) . "\n\n" : "";
- $body .= $_POST ? "\$_POST: " . print_r($_POST, true) . "\n\n" : "";
- $body .= $_COOKIE ? "\$_COOKIE: " . print_r($_COOKIE, true) . "\n\n" : "";
- $body .= $_SERVER ? "\$_SERVER: " . print_r($_SERVER, true) . "\n\n" : "";
- $body .= $fulltrace ? "Stack: " . print_r($fulltrace, true) . "\n\n" : "";
- $body = it::replace(array('(pw|passw|password|secret)\] => .*' => '$1] => ********'), $body);
+
+ if (!$p['omitdebuginfo'])
+ {
+ unset ($p['locals']['GLOBALS'], $p['locals']['_GET'], $p['locals']['_POST'], $p['locals']['_COOKIE']);
+ $locals = print_r($p['locals'], true);
+
+ if ($trace && ($fulltrace = array_slice(debug_backtrace(), $p['backtraceskip'])))
+ while (strlen(print_r($fulltrace, true)) > 100000)
+ array_pop($fulltrace);
+
+ $body .= "Host: " . getenv('HOSTNAME') . "\n\n";
+ $body .= $p['locals'] && strlen($locals) < 100000 ? "Locals: $locals\n\n" : "";
+ $body .= $p['id'] ? "Filter: graceperiod={$p['graceperiod']} timewindow={$p['timewindow']}\n\n" : "";
+ $body .= "Time: " . it::date() . "\n\n";
+ $body .= $lastsentdebug;
+ $body .= $_GET ? "\$_GET: " . print_r($_GET, true) . "\n\n" : "";
+ $body .= $_POST ? "\$_POST: " . print_r($_POST, true) . "\n\n" : "";
+ $body .= $_COOKIE ? "\$_COOKIE: " . print_r($_COOKIE, true) . "\n\n" : "";
+ $body .= $_SERVER ? "\$_SERVER: " . print_r($_SERVER, true) . "\n\n" : "";
+ $body .= $fulltrace ? "Stack: " . print_r($fulltrace, true) . "\n\n" : "";
+ $body = it::replace(array('(pw|passw|password|secret)\] => .*' => '$1] => ********'), $body);
+ }
it::mail(array('To' => $p['to'], 'Subject' => substr($p['title'], 0, 80), 'Body' => $body) + (($cc = $GLOBALS['it_defaultconfig']['error_cc']) ? array('Cc' => $cc) : array()));
}