summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2013-12-12 16:47:33 +0100
committerUrban Müller2013-12-12 16:47:33 +0100
commitee68e001936050a0999bb3fcc12d87fa2fe04bf4 (patch)
tree07eb76ed66b4c4b713736972a0bb55cb4f1ea775
parentdfa062451083811252d469dc5636870def73c5d2 (diff)
downloaditools-ee68e001936050a0999bb3fcc12d87fa2fe04bf4.tar.gz
itools-ee68e001936050a0999bb3fcc12d87fa2fe04bf4.tar.bz2
itools-ee68e001936050a0999bb3fcc12d87fa2fe04bf4.zip
support edge triggered errors, support special chars in blockmailid
-rw-r--r--it.class14
1 files changed, 13 insertions, 1 deletions
diff --git a/it.class b/it.class
index bec2965..a6091e3 100644
--- a/it.class
+++ b/it.class
@@ -120,6 +120,8 @@ static function timerlog($label = '')
* @param $p['skipfiles'] files to skip in backtrace
* @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['okstate'] give current ok label and state, e.g. telresult=1 . see failcount
+ * @param $p['failcount'] give number of consecutive okstate failures needed for creating an error [2]
* @param $p['omitdebuginfo'] Do not add stack dump, locals and environment to output [false]
* @return true if a mail was sent
*/
@@ -144,12 +146,22 @@ static function error($p = array(), $body = null, $to = null) # $body and $to de
'backtraceskip' => 0,
'blockmail' => 3600,
'omitdebuginfo' => false,
+ 'failcount' => 2,
);
$p += array('blockmailid' => md5($p['to']));
@mkdir("/tmp/alertdata");
@chmod("/tmp/alertdata", 0777);
+ if ($p['okstate'])
+ {
+ list($okid, $okstatus) = explode("=", $p['okstate']);
+ $failcount = $okstatus ? 0 : file_get_contents("/tmp/alertdata/$okid") + 1;
+ file_put_contents("/tmp/alertdata/$okid", "$failcount\n");
+ if ($failcount != $p['failcount'])
+ return;
+ }
+
$toscreen = getenv('NOERRORMAILS') || ini_get('display_errors') || (defined("STDOUT") && posix_isatty(STDOUT)) || EDC('astwin') || EDC('asdevel');
@fseek(STDOUT, 0, SEEK_END); # Work around PHP bug 49819: posix_isatty seeks to start
@@ -174,7 +186,7 @@ static function error($p = array(), $body = null, $to = null) # $body and $to de
if ($sendmail)
{
- $lastsentfn = "/tmp/alertdata/lastsent_" . getmyuid() . "." . $p['blockmailid'];
+ $lastsentfn = "/tmp/alertdata/lastsent_" . getmyuid() . "." . urlencode($p['blockmailid']);
$now = time();
clearstatcache();
$lastsenttime = @filemtime($lastsentfn);