-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modify debug mailer remove 404 errors from log
- Loading branch information
Showing
8 changed files
with
57 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BikeShare\App\EventListener; | ||
|
||
use Symfony\Component\HttpKernel\EventListener\ErrorListener as SymfonyErrorListener; | ||
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface; | ||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
class ErrorListener extends SymfonyErrorListener | ||
{ | ||
protected function logException(\Throwable $exception, string $message, string $logLevel = null): void | ||
{ | ||
if (null !== $this->logger) { | ||
if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) { | ||
$this->logger->critical($message, ['exception' => $exception]); | ||
} elseif ($exception instanceof NotFoundHttpException) { | ||
//do not log 404 errors | ||
return; | ||
} else { | ||
$this->logger->error($message, ['exception' => $exception]); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace BikeShare\Mail; | ||
|
||
use Psr\Log\LoggerInterface; | ||
|
||
class DebugMailSender implements MailSenderInterface | ||
{ | ||
private LoggerInterface $logger; | ||
|
||
public function __construct( | ||
LoggerInterface $logger | ||
) { | ||
$this->logger = $logger; | ||
} | ||
|
||
public function sendMail($recipient, $subject, $message) | ||
{ | ||
echo $recipient, ' | ', $subject, ' | ', $message . PHP_EOL; | ||
$this->logger->debug('Sending email', compact('recipient', 'subject', 'message')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters