Skip to content

Commit

Permalink
Ignore send-mail for INFO & DEBUG level in ErrorLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
jzaplet committed Jun 23, 2024
1 parent 1d6bead commit 4815958
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Debugger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 4815958

Please sign in to comment.