From fc907558734ce439f5df2e16ffe1be7b5f30860b Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Wed, 28 Nov 2007 18:28:16 +0000 Subject: dont create stderr for suppressed errors in cli mode --- it.class | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/it.class b/it.class index 056300a..a4231bb 100644 --- a/it.class +++ b/it.class @@ -150,12 +150,12 @@ function error($p = array(), $body = null, $to = null) # $body and $to deprecate 'blockmail' => 3600, ); + @mkdir("/tmp/alertdata"); + @chmod("/tmp/alertdata", 0777); + $toscreen = ini_get('display_errors') || (defined("STDOUT") && posix_isatty(STDOUT)) || EDC('astwin') || EDC('asdevel'); if (!$toscreen) # this error can only be sent by mail: find out if we want to suppress it { - @mkdir("/tmp/alertdata"); - @chmod("/tmp/alertdata", 0777); - if (!$p['id']) $sendmail = true; else @@ -209,11 +209,17 @@ function error($p = array(), $body = null, $to = null) # $body and $to deprecate mail($p['to'], $p['title'], $body, ($cc = $GLOBALS['it_defaultconfig']['error_cc']) ? "Cc: $cc" : null); } - else if ($_SERVER['REMOTE_ADDR']) # in shell mode we rely on error_log below + else if ($_SERVER['REMOTE_ADDR']) # toscreen mode: web echo "
{$p['title']}\n$body
"; + else # toscreen mode: shell (outputs to stderr) + error_log("it::error: " . $p['title'] . " in " . ($trace ? $trace : "{$p['file']}:{$p['line']}") . " Url: $url " . (EDC('verbose') ? D($p['locals']) : "")); } - error_log("it::error: " . $p['title'] . " in " . ($trace ? $trace : "{$p['file']}:{$p['line']}") . " Url: $url " . (EDC('verbose') ? D($p['locals']) : "")); + if (($fh = fopen("/tmp/alertdata/alert.log", "a"))) { + fputs($fh, $p['title'] . " in " . ($trace ? $trace : "{$p['file']}:{$p['line']}") . " Url: $url\n"); + fclose($fh); + @chmod("/tmp/alertdata/alert.log", 0777); + } } -- cgit v1.2.3