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 object. Note that this class only sends the email upon completion, so any log entries accumulated are sent in a single email.

category Zend
package Zend_Log
subpackage Writer
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
version $Id$
inherited_from \Zend_Log_Writer_Abstract

 Methods

Class constructor.

__construct(\Zend_Mail $mail, \Zend_Layout $layout = null) : void

Constructs the mail writer; requires a Zend_Mail instance, and takes an optional Zend_Layout instance. If Zend_Layout is being used, $this->_layout->events will be set for use in the layout template.

Parameters

$mail

\Zend_Mail

Mail instance

$layout

\Zend_Layout

Layout instance; optional

Add a filter specific to this writer.

addFilter(\Zend_Log_Filter_Interface|integer $filter) : \Zend_Log_Writer_Abstract
Inherited

Parameters

$filter

\Zend_Log_Filter_Interfaceinteger

Filter class or filter priority

Exceptions

\Zend_Log_Exception

Returns

\Zend_Log_Writer_Abstract

Create a new instance of Zend_Log_Writer_Mail

factory(array|\Zend_Config $config) : \Zend_Log_Writer_Mail
Static

Parameters

$config

array\Zend_Config

Returns

\Zend_Log_Writer_Mail

Gets instance of Zend_Log_Formatter_Instance used for formatting a message using Zend_Layout, if applicable.

getLayoutFormatter() : \Zend_Log_Formatter_Interface | null

Returns

\Zend_Log_Formatter_InterfacenullThe formatter, or null.

Set a new formatter for this writer

setFormatter(\Zend_Log_Formatter_Interface $formatter) : \Zend_Log_Writer_Abstract
Inherited

Parameters

$formatter

\Zend_Log_Formatter_Interface

Returns

\Zend_Log_Writer_Abstract

Set the layout

setLayout(\Zend_Layout|array $layout) : \Zend_Log_Writer_Mail

Parameters

$layout

\Zend_Layoutarray

Exceptions

\Zend_Log_Exception

Returns

\Zend_Log_Writer_Mail

Sets a specific formatter for use with Zend_Layout events.

setLayoutFormatter(\Zend_Log_Formatter_Interface $formatter) : \Zend_Log_Writer_Mail

Allows use of a second formatter on lines that will be rendered with Zend_Layout. In the event that Zend_Layout is not being used, this formatter cannot be set, so an exception will be thrown.

Parameters

$formatter

\Zend_Log_Formatter_Interface

Exceptions

\Zend_Log_Exception

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 subject can only be set once, this method cannot be used if the Zend_Mail object already has a subject set.

Parameters

$subject

string

Subject prepend text.

Exceptions

\Zend_Log_Exception

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() : void
inherited_from \Zend_Log_Writer_Abstract::shutdown()

Perform shutdown activites such as closing open resources

shutdown() : void
Inherited

Log a message to this writer.

write(array $event) : void
Inherited

Parameters

$event

array

log data event

Construct a Zend_Layout instance based on a configuration array

_constructLayoutFromConfig(array $config) : \Zend_Layout

Parameters

$config

array

Exceptions

\Zend_Log_Exception

Returns

\Zend_Layout

Construct a Zend_Mail instance based on a configuration array

_constructMailFromConfig(array $config) : \Zend_Mail
Static

Parameters

$config

array

Exceptions

\Zend_Log_Exception

Returns

\Zend_Mail

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

_getFormattedNumEntriesPerPriority() : string

Returns

string

Validate and optionally convert the config to array

_parseConfig(array|\Zend_Config $config) : array
InheritedStatic

Parameters

$config

array\Zend_Config

Zend_Config or Array

Exceptions

\Zend_Log_Exception

Returns

array

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

_write(array $event) : void

Handles the formatting of both plaintext entries, as well as those rendered with Zend_Layout.

inherited_from \Zend_Log_Writer_Abstract::_write()

Parameters

$event

array

Event data

Write a message to the log.

_write(array $event) : void
Inherited

Parameters

$event

array

log data event

 Properties

 

Array of formatted events to include in message body.

$_eventsToMail : array

Default

array()
 

of Zend_Log_Filter_Interface

$_filters : array

Default

array()
 

Formats the log message before writing.

$_formatter : \Zend_Log_Formatter_Interface

Default

 

Zend_Layout instance to use; optional.

$_layout : \Zend_Layout

Default

 

Array of formatted lines for use in an HTML email body; these events are formatted with an optional formatter if the caller is using Zend_Layout.

$_layoutEventsToMail : array

Default

array()
 

Optional formatter for use when rendering with Zend_Layout.

$_layoutFormatter : \Zend_Log_Formatter_Interface

Default

 

Zend_Mail instance to use

$_mail : \Zend_Mail

Default

 

MethodMap for Zend_Mail's headers

$_methodMapHeaders : array

Default

array('from' => 'setFrom', 'to' => 'addTo', 'cc' => 'addCc', 'bcc' => 'addBcc')
Static
 

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.