diff options
-rw-r--r-- | it.class | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -207,7 +207,7 @@ static function error($p = array(), $extra = null) 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'])); - $trace = it_debug::backtrace(array('skiplevels' => $p['backtraceskip'] + ($p['trace'] ? 0 : 1), 'skipfiles' => $p['skipfiles'], 'trace' => $p['trace'])); + $traceline = it_debug::backtrace(['skiplevels' => $p['backtraceskip'] + ($p['trace'] ? 0 : 1), 'skipfiles' => $p['skipfiles'], 'trace' => $p['trace']]); @mkdir("/tmp/alertdata"); @chmod("/tmp/alertdata", 0777); @@ -273,11 +273,11 @@ static function error($p = array(), $extra = null) $p['body'] = " See " . getenv('HOSTNAME') . ":$datafn"; } - $mailid = sprintf("mail%04d", crc32($trace ?: $p['title']) % 10000); + $mailid = sprintf("mail%04d", crc32($traceline ?: $p['title']) % 10000); $body = ($p['omitdebuginfo'] >= 2 ? "" : ($url && !$toscreen? "Title: {$p['title']}\nUrl: $url\n" : "") . - ($trace ? ($sendmail ? "" : " ") . "Trace: $trace\n" : "")) . + ($traceline ? ($sendmail ? "" : " ") . "Trace: $traceline\n" : "")) . (!$sendmail || $p['omitdebuginfo'] >= 2 ? "" : "Host: " . getenv('HOSTNAME') . " at " . date("Y-m-d H:i:s") . (($t = time() - $_SERVER['REQUEST_TIME']) ? " (invoked {$t}s before)" : "") . " id $mailid\n") . # no it::date() due to time- debug param ($sendmail ? $p['head'] : "") . ($p['id'] && !$toscreen ? "Filter: timewindow=" . $p['graceperiod'] . "-" . ($p['graceperiod'] + $p['timewindow']) . " (previous err: " . it::date('', $errstamp) . ")\n" : "") . @@ -290,12 +290,12 @@ static function error($p = array(), $extra = null) if (!$p['omitdebuginfo']) { - $backtrace = $p['trace'] ?: array_slice(debug_backtrace(0), $p['backtraceskip']); - $mediumstack = it_debug::backtrace(['trace' => $backtrace, 'format' => "medium"]); - $longstack = it_debug::backtrace(['trace' => $backtrace, 'format' => "long"]); + $trace = $p['trace'] ?: array_slice(debug_backtrace(0), $p['backtraceskip']); + $mediumstack = it_debug::backtrace(['trace' => $trace, 'format' => "medium"]); + $longstack = it_debug::backtrace(['trace' => $trace, 'format' => "long"]); $reqbody = it::file_get_contents("php://input"); - $body .= ($trace and $t = it::exec('grep -h {0} `ls 2>/dev/null {1}/log/alertlog-*|tail -3` /dev/null 2>/dev/null | grep ^2 | cut -d : -f 1-2 | sort | uniq -c | tail -10', $trace, $home)) ? "Histogram: (last 10 affected minutes in 3 days)\n$t\n" : ""; + $body .= ($traceline and $t = it::exec('grep -h {0} `ls 2>/dev/null {1}/log/alertlog-*|tail -3` /dev/null 2>/dev/null | grep ^2 | cut -d : -f 1-2 | sort | uniq -c | tail -10', $traceline, $home)) ? "Histogram: (last 10 affected minutes in 3 days)\n$t\n" : ""; $body .= $mediumstack ? "Stack:\n " . it::replace(["\n" => "\n "], $mediumstack) . "\n" : ""; $body .= $_GET ? "\$_GET: " . var_export($_GET, true) . "\n\n" : ""; $body .= $_POST ? "\$_POST: " . var_export($_POST, true) . "\n\n" : ""; @@ -336,13 +336,13 @@ static function error($p = array(), $extra = null) else if ($_SERVER['REMOTE_ADDR']) # toscreen mode: web echo "<pre style='z-index:10000; position:relative; background:white'>" . htmlspecialchars($p['title'] . "\n" . rtrim($body), ENT_COMPAT, "iso-8859-1") . "</pre>"; # works with iso-8859-1 or utf-8, UTF8SAFE else # toscreen mode: shell (outputs to stderr) - error_log(substr($p['title'], 0, 100000) . ($p['omitdebuginfo'] >= 2 ? "" : " in " . ($trace ? $trace : " {$p['file']}:{$p['line']}") . " Url: $url " . (EDC('verboseerrors') ? D($p['body']) : ""))); + error_log(substr($p['title'], 0, 100000) . ($p['omitdebuginfo'] >= 2 ? "" : " in " . ($traceline ? $traceline : " {$p['file']}:{$p['line']}") . " Url: $url " . (EDC('verboseerrors') ? D($p['body']) : ""))); } if ($_SERVER['REMOTE_ADDR']) # additional entry in log/error_log error_log("it::error: " . $p['title'] . " Url: $url"); - it::log("alertlog", $p['title'] . " in " . ($trace ? $trace : "{$p['file']}:{$p['line']}") . " Url: $url" . ($p['body'] ? "\n" . substr(D($p['body']), 0, 5000) . "\n" : "")); + it::log("alertlog", $p['title'] . " in " . ($traceline ? $traceline : "{$p['file']}:{$p['line']}") . " Url: $url" . ($p['body'] ? "\n" . substr(D($p['body']), 0, 5000) . "\n" : "")); return $p['fatal'] ? self::_exit($p) : null; } |