Class used for writing log messages to email via Zend\Mail.

Allows for emailing log messages at and above a certain level via a Zend\Mail\Message object. Note that this class only sends the email upon completion, so any log entries accumulated are sent in a single email. The email is sent using a Zend\Mail\Transport\TransportInterface object (Sendmail is default).

package Default
inherited_from \Zend\Log\Writer\AbstractWriter

 Methods

Constructor

__construct(\Zend\Mail\Message|array|\Traversable $mail, \Zend\Mail\Transport\TransportInterface $transport = null

Set options for a writer. Accepted options are:

  • filters: array of filters to add to this filter
  • formatter: formatter for this writer
inherited_from \Zend\Log\Writer\AbstractWriter::__construct()

Parameters

$mail

\Zend\Mail\Messagearray\Traversable

$transport

\Zend\Mail\Transport\TransportInterface

Optional

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Constructor

__construct(array|\Traversable $options = null
Inherited

Set options for a writer. Accepted options are:

  • filters: array of filters to add to this filter
  • formatter: formatter for this writer

Parameters

$options

array\Traversable

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Add a filter specific to this writer.

addFilter(integer|string|\Zend\Log\Filter\FilterInterface $filter, array|null $options = null) : \Zend\Log\Writer\AbstractWriter
Inherited
inherited_from \Zend\Log\Writer\WriterInterface::addFilter()

Parameters

$filter

integerstring\Zend\Log\Filter\FilterInterface

$options

arraynull

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Returns

\Zend\Log\Writer\AbstractWriter

Get filter instance

filterPlugin(string $name, array|null $options = null) : \Zend\Log\Filter\FilterInterface
Inherited

Parameters

$name

string

$options

arraynull

Returns

\Zend\Log\Filter\FilterInterface

Get formatter instance

formatterPlugin(string $name, array|null $options = null) : \Zend\Log\Formatter\FormatterInterface
Inherited

Parameters

$name

string

$options

arraynull

Returns

\Zend\Log\Formatter\FormatterInterface

Get filter plugin manager

getFilterPluginManager() : \Zend\Log\Writer\FilterPluginManager
Inherited

Returns

\Zend\Log\Writer\FilterPluginManager

Get formatter plugin manager

getFormatterPluginManager() : \Zend\Log\Writer\FormatterPluginManager
Inherited

Returns

\Zend\Log\Writer\FormatterPluginManager

Set convert write errors to exception flag

setConvertWriteErrorsToExceptions(boolean $convertErrors) 
Inherited

Parameters

$convertErrors

boolean

Set filter plugin manager

setFilterPluginManager(string|\Zend\Log\Writer\FilterPluginManager $plugins) : \Zend\Log\Writer\Mail
Inherited
fluent This method is part of a fluent interface and will return the same instance

Parameters

$plugins

string\Zend\Log\Writer\FilterPluginManager

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Returns

\Zend\Log\Writer\Mail

Set a new formatter for this writer

setFormatter(string|\Zend\Log\Formatter\FormatterInterface $formatter, array|null $options = null) : \Zend\Log\Writer\Mail
Inherited
inherited_from \Zend\Log\Writer\WriterInterface::setFormatter()
fluent This method is part of a fluent interface and will return the same instance

Parameters

$formatter

string\Zend\Log\Formatter\FormatterInterface

$options

arraynull

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Returns

\Zend\Log\Writer\Mail

Set formatter plugin manager

setFormatterPluginManager(string|\Zend\Log\Writer\FormatterPluginManager $plugins) : \Zend\Log\Writer\Mail
Inherited
fluent This method is part of a fluent interface and will return the same instance

Parameters

$plugins

string\Zend\Log\Writer\FormatterPluginManager

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Returns

\Zend\Log\Writer\Mail

Allows caller to have the mail subject dynamically set to contain the entry counts per-priority level.

setSubjectPrependText(string $subject) : \Zend\Log\Writer\Mail

Sets the text for use in the subject, with entry counts per-priority level appended to the end. Since a Zend\Mail\Message subject can only be set once, this method cannot be used if the Zend\Mail\Message object already has a subject set.

Parameters

$subject

string

Subject prepend text

Returns

\Zend\Log\Writer\Mail

Set the transport message

setTransport(\Zend\Mail\Transport\TransportInterface $transport) : \Zend\Log\Writer\Mail

Parameters

$transport

\Zend\Mail\Transport\TransportInterface

Returns

\Zend\Log\Writer\Mail

Sends mail to recipient(s) if log entries are present. Note that both plaintext and HTML portions of email are handled here.

shutdown() 
inherited_from \Zend\Log\Writer\AbstractWriter::shutdown()

Perform shutdown activities such as closing open resources

shutdown() : void
Inherited
inherited_from \Zend\Log\Writer\WriterInterface::shutdown()

Log a message to this writer.

write(array $event) : void
Inherited
inherited_from \Zend\Log\Writer\WriterInterface::write()

Parameters

$event

array

log data event

Places event line into array of lines to be used as message body.

doWrite(array $event) 
inherited_from \Zend\Log\Writer\AbstractWriter::doWrite()

Parameters

$event

array

Event data

Write a message to the log

doWrite(array $event) : void
Inherited

Parameters

$event

array

log data event

Gets a string of number of entries per-priority level that occurred, or an empty string if none occurred.

getFormattedNumEntriesPerPriority() : string

Returns

string

Get formatter

getFormatter() : \Zend\Log\Formatter\FormatterInterface
Inherited

Returns

\Zend\Log\Formatter\FormatterInterface

Check if the writer has a formatter

hasFormatter() : boolean
Inherited

Returns

boolean

 Properties

 

Use Zend\Stdlib\ErrorHandler to report errors during calls to write

$convertWriteErrorsToExceptions : boolean

Default

true
 

Error level passed to Zend\Stdlib\ErrorHandler::start for errors reported during calls to write

$errorsToExceptionsConversionLevel : boolean

Default

E_WARNING
 

Array of formatted events to include in message body.

$eventsToMail : array

Default

array()
 

Filter plugins

$filterPlugins : \Zend\Log\Writer\FilterPluginManager

Default

 

Filter chain

$filters : array<mixed,\Zend\Log\Filter\FilterInterface>

Default

array()
 

Formats the log message before writing

$formatter : \Zend\Log\Formatter\FormatterInterface

Default

 

Formatter plugins

$formatterPlugins : \Zend\Log\Writer\FormatterPluginManager

Default

 

Mail message instance to use

$mail : \Zend\Mail\Message

Default

 

Array keeping track of the number of entries per priority level.

$numEntriesPerPriority : array

Default

array()
 

Subject prepend text.

$subjectPrependText : string | null

Default

Can only be used of the Zend\Mail object has not already had its subject line set. Using this will cause the subject to have the entry counts per-priority level appended to it.

 

Mail transport instance to use; optional.

$transport : \Zend\Mail\Transport\TransportInterface

Default