From 48159580bd252ef5f7308d7aa05a011ac2be329e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Zapletal?= Date: Sun, 23 Jun 2024 17:56:49 +0200 Subject: [PATCH] Ignore send-mail for INFO & DEBUG level in ErrorLogger --- src/Debugger/Logger.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Debugger/Logger.php b/src/Debugger/Logger.php index bf71d16..48b78b5 100644 --- a/src/Debugger/Logger.php +++ b/src/Debugger/Logger.php @@ -64,7 +64,7 @@ public function log($message, string $level = self::INFO): string $this->storage->put("tracy-logs/{$date}--app-json.log", $json); } - if (array_key_exists('LOG_MAIL', $_ENV) && $_ENV['LOG_MAIL'] !== '') { + if (array_key_exists('LOG_MAIL', $_ENV) && $_ENV['LOG_MAIL'] !== '' && !in_array($level, [self::DEBUG, self::INFO])) { $this->sendMail($context); } @@ -110,6 +110,7 @@ private function sendMail(array $context): void { $snooze = strtotime('1 day') - time(); $body = array_map(function ($key, $value) { + $value = is_array($value) ? json_encode($value) : $value; return "{$key}: {$value}"; }, array_keys($context), $context);