From 55b71ecd6a648c0df10b7740f4b3c7bfe4caa083 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 4 Apr 2024 15:07:18 +0200 Subject: append newline to pretty printed json --- it.class | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/it.class b/it.class index 3678d1f..bc28aff 100644 --- a/it.class +++ b/it.class @@ -298,13 +298,13 @@ static function error($p = array(), $extra = null) $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: " . it::json_encode($_GET, ['pretty' => true]) . "\n\n" : ""; - $body .= $_POST ? "\$_POST: " . it::json_encode($_POST, ['pretty' => true]) . "\n\n" : ""; - $body .= $reqbody ? "\$reqbody: " . it::json_encode($reqbody, ['pretty' => true]) . "\n\n" : ""; - $body .= $_COOKIE ? "\$_COOKIE: " . it::json_encode($_COOKIE, ['pretty' => true]) . "\n\n" : ""; + $body .= $_GET ? "\$_GET: " . it::json_encode($_GET, ['pretty' => true]) . "\n" : ""; + $body .= $_POST ? "\$_POST: " . it::json_encode($_POST, ['pretty' => true]) . "\n" : ""; + $body .= $reqbody ? "\$reqbody: " . it::json_encode($reqbody, ['pretty' => true]) . "\n" : ""; + $body .= $_COOKIE ? "\$_COOKIE: " . it::json_encode($_COOKIE, ['pretty' => true]) . "\n" : ""; $body .= $_SERVER['REMOTE_ADDR'] ? "" : "Pstree:\n" . it::exec("pstree -als {pid} | head -n -3", ['pid' => getmypid()]) . "\n"; - $body .= $_SERVER ? "\$_SERVER: " . it::json_encode($_SERVER, ['pretty' => true]) . "\n\n" : ""; - $body .= $_FILES ? "\$_FILES: " . it::json_encode($_FILES, ['pretty' => true]) . "\n\n" : ""; + $body .= $_SERVER ? "\$_SERVER: " . it::json_encode($_SERVER, ['pretty' => true]) . "\n" : ""; + $body .= $_FILES ? "\$_FILES: " . it::json_encode($_FILES, ['pretty' => true]) . "\n" : ""; $body .= "Processes:\n" . it::exec('ps auxf | egrep -v "rotatelogs|getbanner|logaction|httpd|systemd|sd-pam"|egrep "^www|^cron"') . "\n"; $body .= $longstack ? "Full stack: " . "$longstack\n" : ""; $body = it::replace(array('(pw|passw|password\d*|secret)(\' => |\] => |=)[^&\s]*' => '$1$2********'), $body, array('utf8' => false)); @@ -1249,7 +1249,7 @@ static function pipe($cmd, ...$args) */ static function json_encode($data, $p = []) { - return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | ($p['pretty'] ?? it::is_devel() ? JSON_PRETTY_PRINT : 0)); + return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | ($p['pretty'] ?? it::is_devel() ? JSON_PRETTY_PRINT : 0)) . ($p['pretty'] ? "\n" : ""); } /** -- cgit v1.2.3