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

adding exception logging #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

levijackson
Copy link

This taps into the responseReceived event and it logs code + message (401: Cannot send message without a recipient). #34

I'm using this outside of Symfony so my manual test looks like this:

$domain = 'test.com';
// Use incorrect key to verify the error is logged
$apiKey = 'API_KEY';

$eventDispatch = new \Swift_Events_SimpleEventDispatcher();
$mailgun = \Mailgun\Mailgun::create($apiKey);
$transport = new \cspoo\Swiftmailer\MailgunBundle\Service\MailgunTransport($eventDispatch, $mailgun, $domain);
$mailer = Swift_Mailer::newInstance($transport);

$swiftReporter = new Swift_Plugins_Reporters_HitReporter();
$mailer->registerPlugin(new Swift_Plugins_ReporterPlugin($swiftReporter));

$swiftLogger = new Swift_Plugins_Loggers_ArrayLogger();
$mailer->registerPlugin(new Swift_Plugins_LoggerPlugin($swiftLogger));

$message = Swift_Message::newInstance();
$message->setTo('[email protected]')
    ->setFrom('[email protected]')
    ->setSubject('Foo bar')
    ->setBody('test message');

$result = $mailer->send($message);

pr($swiftLogger->dump());

@codecov-io
Copy link

Codecov Report

Merging #56 into master will decrease coverage by 0.3%.
The diff coverage is 80%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #56      +/-   ##
============================================
- Coverage     86.66%   86.36%   -0.31%     
- Complexity       26       28       +2     
============================================
  Files             3        3              
  Lines           105      110       +5     
============================================
+ Hits             91       95       +4     
- Misses           14       15       +1
Impacted Files Coverage Δ Complexity Δ
Service/MailgunTransport.php 80.82% <80%> (-0.07%) 23 <0> (+2)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dd785a2...8320f37. Read the comment docs.

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