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\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).
Synopsis
class Mail
extends AbstractWriter
{
- // members
- protected array $eventsToMail;
- protected Message $mail;
- protected TransportInterface $transport;
- protected array $numEntriesPerPriority;
- protected string|null $subjectPrependText;
- // Inherited members from AbstractWriter
- protected FilterPluginManager $filterPlugins;
- protected FormatterPluginManager $formatterPlugins;
- protected array $filters;
- protected FormatterInterface $formatter;
- protected bool $convertWriteErrorsToExceptions;
- protected bool $errorsToExceptionsConversionLevel;
- // methods
- public void __construct()
- public Mail setTransport()
- protected void doWrite()
- public Mail setSubjectPrependText()
- public void shutdown()
- protected string getFormattedNumEntriesPerPriority()
- // Inherited methods from AbstractWriter
- public Logger __construct()
- public AbstractWriter addFilter()
- public FilterPluginManager getFilterPluginManager()
- public self setFilterPluginManager()
- public FilterInterface filterPlugin()
- public FormatterPluginManager getFormatterPluginManager()
- public self setFormatterPluginManager()
- public FormatterInterface formatterPlugin()
- public void write()
- public self setFormatter()
- protected FormatterInterface getFormatter()
- protected bool hasFormatter()
- public void setConvertWriteErrorsToExceptions()
- public void shutdown()
- protected abstract void doWrite()
Hierarchy
Extends
Members
protected
- $convertWriteErrorsToExceptions
—
Zend\Log\Writer\bool
Use Zend\Stdlib\ErrorHandler to report errors during calls to write - $errorsToExceptionsConversionLevel
—
Zend\Log\Writer\bool
Error level passed to Zend\Stdlib\ErrorHandler::start for errors reported during calls to write - $eventsToMail
—
array
Array of formatted events to include in message body. - $filterPlugins
—
Zend\Log\Writer\FilterPluginManager
Filter plugins - $filters
—
array
Filter chain - $formatter
—
Zend\Log\Writer\Formatter\FormatterInterface
Formats the log message before writing - $formatterPlugins
—
Zend\Log\Writer\FormatterPluginManager
Formatter plugins - $mail
—
Zend\Mail\Message
Mail message instance to use - $numEntriesPerPriority
—
array
Array keeping track of the number of entries per priority level. - $subjectPrependText
—
Zend\Log\Writer\string|null
Subject prepend text. - $transport
—
Zend\Log\Writer\Transport\TransportInterface
Mail transport instance to use; optional.
Methods
protected
- doWrite() — Places event line into array of lines to be used as message body.
- getFormattedNumEntriesPerPriority() — Gets a string of number of entries per-priority level that occurred, or an empty string if none occurred.
public
- __construct() — Constructor
- setSubjectPrependText() — Allows caller to have the mail subject dynamically set to contain the entry counts per-priority level.
- setTransport() — Set the transport message
- shutdown() — Sends mail to recipient(s) if log entries are present. Note that both plaintext and HTML portions of email are handled here.
Inherited from Zend\Log\Writer\AbstractWriter
protected
- doWrite() — Write a message to the log
- getFormatter() — Get formatter
- hasFormatter() — Check if the writer has a formatter
public
- addFilter() — Add a filter specific to this writer.
- filterPlugin() — Get filter instance
- formatterPlugin() — Get formatter instance
- getFilterPluginManager() — Get filter plugin manager
- getFormatterPluginManager() — Get formatter plugin manager
- setConvertWriteErrorsToExceptions() — Set convert write errors to exception flag
- setFilterPluginManager() — Set filter plugin manager
- setFormatter() — Set a new formatter for this writer
- setFormatterPluginManager() — Set formatter plugin manager
- shutdown() — Perform shutdown activities such as closing open resources
- write() — Log a message to this writer.