Log/Writer/Mail.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Log
- Subpackage
- Writer
- Version
- $Id: Mail.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Log_Writer_Mail
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.
- Parent(s)
- \Zend_Log_Writer_Abstract
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Version
- $Id: Mail.php 24593 2012-01-05 20:35:02Z matthew $
Properties

array $_eventsToMail = array()Array of formatted events to include in message body.
array()Details- Type
- array

array $_filters = array()array()Details- Type
- array
- Inherited_from
- \Zend_Log_Writer_Abstract::$$_filters

\Zend_Log_Formatter_Interface $_formatter = Formats the log message before writing.
Inherited from: \Zend_Log_Writer_Abstract::$$_formatter- Type
- \Zend_Log_Formatter_Interface
- Inherited_from
- \Zend_Log_Writer_Abstract::$$_formatter

array $_layoutEventsToMail = array()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.
array()Details- Type
- array

\Zend_Log_Formatter_Interface $_layoutFormatter = Optional formatter for use when rendering with Zend_Layout.

array $_methodMapHeaders = array('from' => 'setFrom', 'to' => 'addTo', 'cc' => 'addCc', 'bcc' => 'addBcc')MethodMap for Zend_Mail's headers
array('from' => 'setFrom', 'to' => 'addTo', 'cc' => 'addCc', 'bcc' => 'addBcc')Details- Type
- array

array $_numEntriesPerPriority = array()Array keeping track of the number of entries per priority level.
array()Details- Type
- array
Methods

__construct(\Zend_Mail $mail, \Zend_Layout $layout = null) : voidClass constructor.
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.
| Name | Type | Description |
|---|---|---|
| \Zend_Mail | Mail instance |
|
| $layout | \Zend_Layout | Layout instance; optional |

_constructLayoutFromConfig(array $config) : \Zend_LayoutConstruct a Zend_Layout instance based on a configuration array
| Name | Type | Description |
|---|---|---|
| $config | array |
| Type | Description |
|---|---|
| \Zend_Layout |
| Exception | Description |
|---|---|
| \Zend_Log_Exception |

_constructMailFromConfig(array $config) : \Zend_MailConstruct a Zend_Mail instance based on a configuration array
| Name | Type | Description |
|---|---|---|
| $config | array |
| Type | Description |
|---|---|
| \Zend_Mail |
| Exception | Description |
|---|---|
| \Zend_Log_Exception |

_getFormattedNumEntriesPerPriority() : stringGets a string of number of entries per-priority level that occurred, or an emptry string if none occurred.
| Type | Description |
|---|---|
| string |

_parseConfig(array | \Zend_Config $config) : arrayValidate and optionally convert the config to array
Inherited from: \Zend_Log_Writer_Abstract::_parseConfig()| Name | Type | Description |
|---|---|---|
| $config | array | \Zend_Config | Zend_Config or Array |
| Type | Description |
|---|---|
| array |
| Exception | Description |
|---|---|
| \Zend_Log_Exception |

_write(array $event) : voidPlaces event line into array of lines to be used as message body.
Handles the formatting of both plaintext entries, as well as those rendered with Zend_Layout.
| Name | Type | Description |
|---|---|---|
| $event | array | Event data |

addFilter(\Zend_Log_Filter_Interface $filter) : \Zend_Log_Writer_AbstractAdd a filter specific to this writer.
Inherited from: \Zend_Log_Writer_Abstract::addFilter()| Name | Type | Description |
|---|---|---|
| $filter | \Zend_Log_Filter_Interface |
| Type | Description |
|---|---|
| \Zend_Log_Writer_Abstract |

factory(array | \Zend_Config $config) : \Zend_Log_Writer_MailCreate a new instance of Zend_Log_Writer_Mail
| Name | Type | Description |
|---|---|---|
| $config | array | \Zend_Config |
| Type | Description |
|---|---|
| \Zend_Log_Writer_Mail |

getLayoutFormatter() : \Zend_Log_Formatter_Interface | nullGets instance of Zend_Log_Formatter_Instance used for formatting a message using Zend_Layout, if applicable.
| Type | Description |
|---|---|
| \Zend_Log_Formatter_Interface | null | The formatter, or null. |

setFormatter(\Zend_Log_Formatter_Interface $formatter) : \Zend_Log_Writer_AbstractSet a new formatter for this writer
Inherited from: \Zend_Log_Writer_Abstract::setFormatter()| Name | Type | Description |
|---|---|---|
| $formatter | \Zend_Log_Formatter_Interface |
| Type | Description |
|---|---|
| \Zend_Log_Writer_Abstract |

setLayout(\Zend_Layout | array $layout) : \Zend_Log_Writer_MailSet the layout
| Name | Type | Description |
|---|---|---|
| $layout | \Zend_Layout | array |
| Type | Description |
|---|---|
| \Zend_Log_Writer_Mail |
| Exception | Description |
|---|---|
| \Zend_Log_Exception |

setLayoutFormatter(\Zend_Log_Formatter_Interface $formatter) : \Zend_Log_Writer_MailSets a specific formatter for use with Zend_Layout events.
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.
| Name | Type | Description |
|---|---|---|
| $formatter | \Zend_Log_Formatter_Interface |
| Type | Description |
|---|---|
| \Zend_Log_Writer_Mail |
| Exception | Description |
|---|---|
| \Zend_Log_Exception |

setSubjectPrependText(string $subject) : \Zend_Log_Writer_MailAllows caller to have the mail subject dynamically set to contain the entry counts per-priority level.
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.
| Name | Type | Description |
|---|---|---|
| $subject | string | Subject prepend text. |
| Type | Description |
|---|---|
| \Zend_Log_Writer_Mail |
| Exception | Description |
|---|---|
| \Zend_Log_Exception |

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