From 47af49faf2d4f65c87cb9d6ac4e731246fe848cd Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Mon, 24 Sep 2007 14:41:28 +0000 Subject: sparse it:error output in shell mode --- it.class | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index eb3cafe..837e33c 100644 --- a/it.class +++ b/it.class @@ -122,27 +122,26 @@ function error($p = array(), $body = "", $to = "") $sendalert = true; } - if ($sendalert && (!ereg('live', $GLOBALS['ULTRASERVERTYPE']) || (time() - @filemtime($lastsentfn)) > 3600)) + $toscreen = !ereg('live', $GLOBALS['ULTRASERVERTYPE']); + + if ($sendalert && ($toscreen || (time() - @filemtime($lastsentfn)) > 3600)) { @mkdir("/tmp/alertdata"); @chmod("/tmp/alertdata", 0777); touch($lastsentfn); @chmod($lastsentfn, 0666); - $url = ($_SERVER['HTTPS'] ? "https://" : "http://") . $_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI']; + if ($_SERVER['REMOTE_ADDR']) + $url = ($_SERVER['HTTPS'] ? "https://" : "http://") . $_SERVER['HTTP_HOST'] .$_SERVER['REQUEST_URI']; if (!$title) - $title="Error in $url"; + $title="Error in " . trim($url); if (!function_exists('memory_get_usage') || (memory_get_usage() < 50000000)) - $trace = "\n\nTrace: " . it_debug::backtrace($p['backtraceskip']); + $trace = it_debug::backtrace($p['backtraceskip']); - $body .= "\nUrl: $url$trace"; + $body .= ($url ? "\nUrl: $url" : "") . ($trace ? "\n\nTrace: " . $trace : ""); - if (!ereg('live', $GLOBALS['ULTRASERVERTYPE'])) - { - echo "
$title\n$body\n
"; - } - else + if (!$toscreen) { $cmd = "alert -l " . escapeshellarg($to) . " 4 " . escapeshellarg($title); @@ -154,9 +153,11 @@ function error($p = array(), $body = "", $to = "") pclose($pipe); } } + else if ($_SERVER['REMOTE_ADDR']) + echo "
$title\n$body\n
"; } - error_log("it::error: ".$title); + error_log("it::error: ".$title . ": " . $trace . (EDC('verbose') ? D($p['locals']) : "")); } -- cgit v1.2.3