summaryrefslogtreecommitdiff
path: root/it.class
diff options
context:
space:
mode:
authorUrban Müller2017-08-11 14:17:26 +0200
committerUrban Müller2017-08-11 14:17:26 +0200
commit3cb19b313b2363ff326d2baa01bca13c55866deb (patch)
treef0ee0845b269238f3e4ca5959ebdcfbd1a4c2aa2 /it.class
parentdffa2d3fc3af4836d2a7241e924dc84a4ae57870 (diff)
downloaditools-3cb19b313b2363ff326d2baa01bca13c55866deb.tar.gz
itools-3cb19b313b2363ff326d2baa01bca13c55866deb.tar.bz2
itools-3cb19b313b2363ff326d2baa01bca13c55866deb.zip
support new timewindow syntax
Diffstat (limited to 'it.class')
-rw-r--r--it.class24
1 files changed, 16 insertions, 8 deletions
diff --git a/it.class b/it.class
index 2107671..8934ef7 100644
--- a/it.class
+++ b/it.class
@@ -117,9 +117,9 @@ static function timerlog($label = '')
* @param $p['title'] error title, one line. also accepted in $p[0] (with priority). false means ignore error
* @param $p['body'] error body: multiline string or any data type (will be dumped)
* @param $p['to'] comma separated recipient list
- * @param $p['id'] id of error. if given, first error is suppressed and second has to occur after 'graceperiod' within 'timewindow'
- * @param $p['graceperiod'] in seconds. see 'id' [60]
- * @param $p['timewindow'] in seconds. see 'id' [25*3600]
+ * @param $p['id'] id of error, used with timewindow, defaults to file and line of caller
+ * @param $p['graceperiod'] in seconds. deprecated, see $p['timewindow']
+ * @param $p['timewindow'] in secs. "5-35" means for an notice to be sent, a second error must occur 5 to 35 seconds after first err
* @param $p['blockmailid'] block mail for $p['blockmail'] seconds with same id. Default: $p['to']
* @param $p['blockmail'] number of seconds to block mails after having sent a mail [3600]
* @param $p['backtraceskip'] number of stack levels to drop
@@ -129,15 +129,20 @@ static function timerlog($label = '')
* @param $p['omitdebuginfo'] value 1 omits long stack and var dumps, value 2 also omits trace and url
* @param $p['fatal'] exit after displaying error
* @return always null (so users can return it::error() in error cases)
- * EXAMPLES (m: mail, x: no mail)
- * time ---|graceperiod|timewindow|
- * |graceperiod|timewindow|--.
- * |graceperiod|timewindow|------>
- * id x x x m x x x x
*
+ * TIMEWINDOW 5-35 (x = error occurs, no mail; m = error occurs, mail sent)
+ * time ---|5 secs|30 secs |------|5 secs|30 secs
+ * |5 secs|30 secs
+ * x x x x m x m x
+ * BLOCKMAIL
* time ---|blockmail|--|blockmail|---->
* blockmailid m x x m x
*
+ * GRACPERIOD/TIMEWINDOW (DEPRECATED, graceperiod is first argument of 5-35, timewindow is difference between 5 and 35)
+ * time ---|graceperiod|timewindow|
+ * |graceperiod|timewindow|--.
+ * |graceperiod|timewindow|------>
+ * id x x x m x x x x
*/
static function error($p = array())
{
@@ -164,7 +169,10 @@ static function error($p = array())
'blockmail' => 3600,
'omitdebuginfo' => false,
'failcount' => 2,
+ 'id' => $p['timewindow'] ? "it_error_id_" . it_debug::backtrace(['skipfiles' => "it.class", 'levels' => 1]) : 0,
);
+ if (it::match('-', $p['timewindow']) && ($parts = explode("-", $p['timewindow'])))
+ list($p['graceperiod'], $p['timewindow']) = [$parts[0], $parts[1] - $parts[0]];
$p += array('blockmailid' => $GLOBALS['ULTRASITE'] . "." . md5($p['to']));
@mkdir("/tmp/alertdata");