summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUrban Müller2024-04-04 15:07:18 +0200
committerUrban Müller2024-04-04 15:07:29 +0200
commit55b71ecd6a648c0df10b7740f4b3c7bfe4caa083 (patch)
tree5df67639724fdea9ddee0424cdcfb77d18e5cc91
parent2e1c213dd0804d6820bb8ba7705a598630032d9f (diff)
downloaditools-55b71ecd6a648c0df10b7740f4b3c7bfe4caa083.tar.gz
itools-55b71ecd6a648c0df10b7740f4b3c7bfe4caa083.tar.bz2
itools-55b71ecd6a648c0df10b7740f4b3c7bfe4caa083.zip
append newline to pretty printed json
-rw-r--r--it.class14
1 files 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" : "");
}
/**