Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SwiftMailer] send error log mails from CLI #73

Merged
merged 1 commit into from
Mar 26, 2014

Conversation

arodiss
Copy link
Contributor

@arodiss arodiss commented Mar 26, 2014

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/symfony#10534

@arodiss arodiss changed the title [ SwiftMailer ] send error log mails from CLI [SwiftMailer] send error log mails from CLI Mar 26, 2014
@@ -341,6 +341,7 @@ private function buildHandler(ContainerBuilder $container, $name, array $handler
if (!$oldHandler) {
$this->swiftMailerHandlers[] = $handlerId;
$definition->addTag('kernel.event_listener', array('event' => 'kernel.terminate', 'method' => 'onKernelTerminate'));
$definition->addTag('kernel.event_listener', array('event' => 'console.terminate', 'method' => 'onCliTerminate'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be wrapped in a if (method_exists($newHandlerClass, 'onCliTerminate')) to make sure the symfony version is recent enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Seldaek
right you are
Updated code and set BC break to no

@Seldaek
Copy link
Member

Seldaek commented Mar 26, 2014

Alright thanks, I'll merge whenever it gets merged in symfony, in case something would change in the meantime.

fabpot added a commit to symfony/symfony that referenced this pull request Mar 26, 2014
…m 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
@arodiss
Copy link
Contributor Author

arodiss commented Mar 26, 2014

@Seldaek
counterpart merged in sf

Seldaek added a commit that referenced this pull request Mar 26, 2014
[SwiftMailer] send error log mails from CLI
@Seldaek Seldaek merged commit 60aa10d into symfony:master Mar 26, 2014
@Seldaek
Copy link
Member

Seldaek commented Mar 26, 2014

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants