From a8a79ede824088ecb1aee300b04c2cd96b8f1399 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Fri, 12 Mar 2021 16:16:14 +0100 Subject: allow forcing errors to screen --- it.class | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'it.class') diff --git a/it.class b/it.class index 1a54a58..723a202 100644 --- a/it.class +++ b/it.class @@ -21,7 +21,7 @@ class it { -static $error_context; # Text that will be added to all it_error mails +static $error_context; # Callback, can provide $result['head'] and $result['toscreen'] /** * Create config class with static members initialized (e.g. $home). @@ -207,7 +207,9 @@ static function error($p = array(), $extra = null) return; } - $toscreen = getenv('NOERRORMAILS') || ini_get('display_errors') || (defined("STDOUT") && posix_isatty(STDERR)) || EDC('astwin') || EDC('asdevel'); + $context = is_callable(self::$error_context) ? (self::$error_context)() : []; + + $toscreen = getenv('NOERRORMAILS') || ini_get('display_errors') || (defined("STDOUT") && posix_isatty(STDERR)) || EDC('astwin') || EDC('asdevel') || $context['toscreen']; if ($toscreen && !it::is_live()) $GLOBALS['debug_noredir'] = 1; @@ -263,7 +265,7 @@ static function error($p = array(), $extra = null) ($p['omitdebuginfo'] >= 2 ? "" : ($url && !$toscreen? "Title: {$p['title']}\nUrl: $url\n" : "") . ($trace ? ($sendmail ? "" : " ") . "Trace: $trace\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)" : "") . "\n") . # no it::date() due to time- debug param - ($sendmail ? self::$error_context : "") . + ($sendmail ? $context['head'] : "") . ($p['id'] ? "Filter: timewindow=" . $p['graceperiod'] . "-" . ($p['graceperiod'] + $p['timewindow']) . " (previous err: " . it::date('', $errstamp) . ")\n" : "") . (!$origp['blockmail'] || $p['omitdebuginfo'] || $toscreen ? "" : "Block-resend: " . $origp['blockmail'] . " seconds\n") . ($p['body'] ? ($p['omitdebuginfo'] ? "" : "Body:\n") . trim($p['body'])."\n\n" : ""); -- cgit v1.2.3