Skip to content

Commit 790ba4c

Browse files
committed
feature #10534 [SwiftMailer] [MonologBundle] send error log mails from CLI (arodiss)
This PR was merged into the 2.5-dev branch. Discussion ---------- [SwiftMailer] [MonologBundle] send error log mails from CLI | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | License | MIT Given I have symfony2 application with Monolog configured to send mail on error logs. When I have exception thrown from CLI task Then I should receive error mail However this is not true because `Monolog/SwiftMailerHandler` is doing force flush only on `kernel.terminate`, but not on `console.terminate` This PR fixes issue together with symfony/monolog-bundle#73 Commits ------- 9bb602f added explicit swiftmailer flush after ConsoleEvents::TERMINATE
2 parents 9dc14a5 + 9bb602f commit 790ba4c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Symfony/Bridge/Monolog/Handler/SwiftMailerHandler.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\Monolog\Handler;
1313

1414
use Monolog\Handler\SwiftMailerHandler as BaseSwiftMailerHandler;
15+
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
1516
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
1617

1718
/**
@@ -43,6 +44,16 @@ public function onKernelTerminate(PostResponseEvent $event)
4344
$this->instantFlush = true;
4445
}
4546

47+
/**
48+
* After the CLI application has been terminated we will always flush messages
49+
*
50+
* @param ConsoleTerminateEvent $event
51+
*/
52+
public function onCliTerminate(ConsoleTerminateEvent $event)
53+
{
54+
$this->instantFlush = true;
55+
}
56+
4657
/**
4758
* {@inheritdoc}
4859
*/

0 commit comments

Comments
 (0)