1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-02-23 22:42:38 +01:00

Adding a new maxColumnWidth property see #217

This commit is contained in:
Julio Montoya 2013-08-09 13:40:03 +02:00
parent 207039c326
commit 7717c4f1df

View File

@ -25,6 +25,7 @@ class NativeMailerHandler extends MailHandler
protected $headers = array(
'Content-type: text/plain; charset=utf-8'
);
protected $maxColumnWidth;
/**
* @param string|array $to The receiver of the mail
@ -32,13 +33,15 @@ class NativeMailerHandler extends MailHandler
* @param string $from The sender of the mail
* @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
* @param int $maxColumnWidth The maximum column width that the message lines will have
*/
public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true)
public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true, $maxColumnWidth = 70)
{
parent::__construct($level, $bubble);
$this->to = is_array($to) ? $to : array($to);
$this->subject = $subject;
$this->addHeader(sprintf('From: %s', $from));
$this->maxColumnWidth = $maxColumnWidth;
}
/**
@ -59,7 +62,7 @@ class NativeMailerHandler extends MailHandler
*/
protected function send($content, array $records)
{
$content = wordwrap($content, 70);
$content = wordwrap($content, $this->maxColumnWidth);
$headers = implode("\r\n", $this->headers) . "\r\n";
foreach ($this->to as $to) {
mail($to, $this->subject, $content, $headers);