diff options
-rw-r--r-- | it.class | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -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"); |