summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--it.class13
1 files changed, 7 insertions, 6 deletions
diff --git a/it.class b/it.class
index 091f026..e24ddf5 100644
--- a/it.class
+++ b/it.class
@@ -169,6 +169,7 @@ static function error($p = array(), $extra = null)
$p['title'] = $p[0] ?: $p['title']; # handle 'it_error' => "oops" that was cast to array on the way
$p['title'] = grapheme_substr($p['title'], 0, 2000) ?: substr($p['title'], 0, 2000);
+ $home = $GLOBALS['ULTRAHOME'];
# support for errlike() in tests
$GLOBALS['ULTRAERROR'] = $p['title'];
@@ -187,7 +188,7 @@ static function error($p = array(), $extra = null)
else
$url = $_SERVER['SCRIPT_NAME'] . " " . implode(" ", array_slice($GLOBALS['argv'], 1)) . " (pwd " . $_SERVER['PWD'] . ")";
- $authors = it::replace(['\*' => ""], join(", ", it::grep('\*', (array)@it::cat($GLOBALS['ULTRAHOME'] . "/.diffnotice")->lines, ['invert' => true])));
+ $authors = it::replace(['\*' => ""], join(", ", it::grep('\*', (array)@it::cat("$home/.diffnotice")->lines, ['invert' => true])));
if (!$p['to'])
unset($p['to']); # allow defaults to kick in
$p += array(
@@ -211,7 +212,7 @@ static function error($p = array(), $extra = null)
if ($p['okstate'])
{
- list($okfn, $okstatus) = explode("=", "/tmp/alertdata/okstate_" . $p['okstate']);
+ list($okfn, $okstatus) = explode("=", "$home/okstate_" . $p['okstate']);
$failcount = $okstatus ? 0 : (int)@file_get_contents($okfn) + 1; # NOPHPLINT
file_put_contents($okfn, "$failcount\n"); # NOPHPLINT
if ($failcount != $p['failcount'] && $failcount != $p['failcount'] * 30)
@@ -268,7 +269,7 @@ static function error($p = array(), $extra = null)
$p['body'] = is_string($p['body']) || !array_key_exists('body', $p) ? $p['body'] : it_debug::dump([$p['body']], ['html' => false, 'short' => true, 'color' => false]);
if (strlen($p['body']) > 500000 || it::match('[\x00-\x08\x0E-\x1F]', $p['body'], ['utf8' => false]) !== null)
{
- file_put_contents($datafn = "/tmp/alertdata/error-" . substr(md5($p['body']), 0, 2), $p['body']); # NOPHPLINT
+ file_put_contents($datafn = "$home/error-" . substr(md5($p['body']), 0, 2), $p['body']); # NOPHPLINT
$p['body'] = "Body: " . getenv('HOSTNAME') . ":$datafn";
}
@@ -293,7 +294,7 @@ static function error($p = array(), $extra = null)
$reqbody = it::file_get_contents("php://input");
- $body .= ($trace and $t = it::exec('grep -h {0} `ls /tmp/alertdata/alertlog-*|tail -3` /dev/null 2>/dev/null | grep ^2 | cut -d : -f 1-2 | sort | uniq -c | tail -10', $trace)) ? "Histogram: (last 10 affected minutes in 3 days)\n$t" : "";
+ $body .= ($trace and $t = it::exec('grep -h {0} `ls {1}/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" : "";
$body .= "\n";
$body .= $_GET ? "\$_GET: " . var_export($_GET, true) . "\n\n" : "";
$body .= $_POST ? "\$_POST: " . var_export($_POST, true) . "\n\n" : "";
@@ -309,7 +310,7 @@ static function error($p = array(), $extra = null)
$type = ($p['fatal'] ? (it::is_live() ? "FATAL: " : "Fatal: ") : "Error: ");
$debugparams = it::match('\.([^-.]+)', $_SERVER['HTTP_HOST'], ['all' => true]);
- if (!it::is_live() || array_diff($debugparams, it::match('[-\w]+', $GLOBALS['ULTRAHOME'], ['all' => true]), ["devel", "twin", gethostname()]))
+ if (!it::is_live() || array_diff($debugparams, it::match('[-\w]+', $home, ['all' => true]), ["devel", "twin", gethostname()]))
$type = mb_strtolower($type);
$user = posix_getpwuid(posix_geteuid())['name'];
@@ -336,7 +337,7 @@ static function error($p = array(), $extra = null)
if ($_SERVER['REMOTE_ADDR']) # additional entry in log/error_log
error_log("it::error: " . $p['title'] . " Url: $url");
- it::log("/tmp/alertdata/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 " . ($trace ? $trace : "{$p['file']}:{$p['line']}") . " Url: $url" . ($p['body'] ? "\n" . substr(D($p['body']), 0, 5000) . "\n" : ""));
return $p['fatal'] ? self::_exit($p) : null;
}