From b66b5f3b3c80cd095640e93a9d074c43f949a797 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sun, 8 May 2011 17:18:14 +0200 Subject: [PATCH 1/2] Added the possibility to configure the message using a callback in SwiftMailerHandler --- src/Monolog/Handler/SwiftMailerHandler.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Monolog/Handler/SwiftMailerHandler.php b/src/Monolog/Handler/SwiftMailerHandler.php index 8a400032..d7a79132 100644 --- a/src/Monolog/Handler/SwiftMailerHandler.php +++ b/src/Monolog/Handler/SwiftMailerHandler.php @@ -25,14 +25,20 @@ class SwiftMailerHandler extends MailHandler /** * @param \Swift_Mailer $mailer The mailer to use - * @param \Swift_Message $message An example message for real messages, only the body will be replaced + * @param callback|\Swift_Message $message An example message for real messages, only the body will be replaced * @param integer $level The minimum logging level at which this handler will be triggered * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not */ - public function __construct(\Swift_Mailer $mailer, \Swift_Message $message, $level = Logger::ERROR, $bubble = false) + public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = false) { parent::__construct($level, $bubble); $this->mailer = $mailer; + if (!$message instanceof \Swift_Message && is_callable($message)) { + $message = call_user_func($message); + } + if (!$message instanceof \Swift_Message) { + throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callback returning it'); + } $this->message = $message; } From 6dd6f040e8bf6f8f4ad1d20f2e77f4e69ed11576 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sun, 8 May 2011 18:26:39 +0200 Subject: [PATCH 2/2] Updated README --- README.mdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.mdown b/README.mdown index 83d0893c..3004bd00 100644 --- a/README.mdown +++ b/README.mdown @@ -34,16 +34,16 @@ Notable Features (non-exhaustive and incomplete) - _FingersCrossedHandler_: A very interesting handler. It takes a logger as parameter and will accumulate log records of all levels until a record exceeds the defined severity level. At which point it delivers all records, including those of lower severity, to the handler it wraps. This means that until an error actually happens you will not see anything in your logs, but when it happens you will have the full information, including debug and info records. This provides you with the info you need, only when you need it. - _FirePHPHandler_: Handler for [FirePHP](http://www.firephp.org/), providing inline `console` messages within [FireBug](http://getfirebug.com/). -Todo ----- - -- MailHandler - Requirements ------------ Any flavor of PHP 5.3 should do +Submitting bugs and feature requests +------------------------------------ + +Bugs and feature request are tracked on [Github](https://github.com/Seldaek/monolog/issues) + Author ------