mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-06 13:16:39 +02:00
Fixes
This commit is contained in:
@@ -53,8 +53,10 @@ abstract class MailHandler extends AbstractHandler
|
||||
$messages[] = $record['message'];
|
||||
}
|
||||
|
||||
if (!empty($messages)) {
|
||||
$this->send($this->createMessage($messages));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the message format
|
||||
|
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Monolog\Handler;
|
||||
|
||||
use Monolog\Logger;
|
||||
|
||||
/**
|
||||
* SwiftMailerHandler uses Swift_Mailer to send the emails
|
||||
*
|
||||
@@ -26,11 +28,15 @@ 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 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)
|
||||
public function __construct(\Swift_Mailer $mailer, \Swift_Message $message, $level = Logger::ERROR, $bubble = false)
|
||||
{
|
||||
$this->mailer = $mailer;
|
||||
$this->message = $message;
|
||||
$this->level = $level;
|
||||
$this->bubble = $bubble;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -37,6 +37,22 @@ class MailHandlerTest extends TestCase
|
||||
$handler->handleBatch($records);
|
||||
}
|
||||
|
||||
public function testHandleBatchNotSendsMailIfMessagesAreBelowLevel()
|
||||
{
|
||||
$records = array(
|
||||
$this->getRecord(Logger::DEBUG, 'debug message 1'),
|
||||
$this->getRecord(Logger::DEBUG, 'debug message 2'),
|
||||
$this->getRecord(Logger::INFO, 'information'),
|
||||
);
|
||||
|
||||
$handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler');
|
||||
$handler->expects($this->never())
|
||||
->method('send');
|
||||
$handler->setLevel(Logger::ERROR);
|
||||
|
||||
$handler->handleBatch($records);
|
||||
}
|
||||
|
||||
public function testHandle()
|
||||
{
|
||||
$record = $this->getRecord();
|
||||
|
Reference in New Issue
Block a user