Logging messages with a stack of backends

package Default

 Methods

Constructor

__construct(array|\Traversable $options = null) : \Zend\Log\Logger

Set options for a logger. Accepted options are:

  • writers: array of writers to add to this logger
  • exceptionhandler: if true register this logger as exceptionhandler
  • errorhandler: if true register this logger as errorhandler

Parameters

$options

array\Traversable

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Returns

\Zend\Log\Logger

Shutdown all writers

__destruct() : void

Add a processor to a logger

addProcessor(string|\Zend\Log\Processor\ProcessorInterface $processor, integer $priority = 1, array|null $options = null) : \Zend\Log\Logger

Parameters

$processor

string\Zend\Log\Processor\ProcessorInterface

$priority

integer

$options

arraynull

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Returns

\Zend\Log\Logger

Add a writer to a logger

addWriter(string|\Zend\Log\Writer\WriterInterface $writer, integer $priority = 1, array|null $options = null) : \Zend\Log\Logger

Parameters

$writer

string\Zend\Log\Writer\WriterInterface

$priority

integer

$options

arraynull

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Returns

\Zend\Log\Logger

alert()

alert(string $message, array|\Traversable $extra = array()) : \Zend\Log\Logger
inherited_from \Zend\Log\LoggerInterface::alert()

Parameters

$message

string

$extra

array\Traversable

Returns

\Zend\Log\Logger

crit()

crit(string $message, array|\Traversable $extra = array()) : \Zend\Log\Logger
inherited_from \Zend\Log\LoggerInterface::crit()

Parameters

$message

string

$extra

array\Traversable

Returns

\Zend\Log\Logger

debug()

debug(string $message, array|\Traversable $extra = array()) : \Zend\Log\Logger
inherited_from \Zend\Log\LoggerInterface::debug()

Parameters

$message

string

$extra

array\Traversable

Returns

\Zend\Log\Logger

emerg()

emerg(string $message, array|\Traversable $extra = array()) : \Zend\Log\Logger
inherited_from \Zend\Log\LoggerInterface::emerg()

Parameters

$message

string

$extra

array\Traversable

Returns

\Zend\Log\Logger

err()

err(string $message, array|\Traversable $extra = array()) : \Zend\Log\Logger
inherited_from \Zend\Log\LoggerInterface::err()

Parameters

$message

string

$extra

array\Traversable

Returns

\Zend\Log\Logger

Get processor plugin manager

getProcessorPluginManager() : \Zend\Log\ProcessorPluginManager

Returns

\Zend\Log\ProcessorPluginManager

Get processors

getProcessors() : \Zend\Stdlib\SplPriorityQueue

Returns

\Zend\Stdlib\SplPriorityQueue

Get writer plugin manager

getWriterPluginManager() : \Zend\Log\WriterPluginManager

Returns

\Zend\Log\WriterPluginManager

Get writers

getWriters() : \Zend\Stdlib\SplPriorityQueue

Returns

\Zend\Stdlib\SplPriorityQueue

info()

info(string $message, array|\Traversable $extra = array()) : \Zend\Log\Logger
inherited_from \Zend\Log\LoggerInterface::info()

Parameters

$message

string

$extra

array\Traversable

Returns

\Zend\Log\Logger

Add a message as a log entry

log(integer $priority, mixed $message, array|\Traversable $extra = array()) : \Zend\Log\Logger

Parameters

$priority

integer

$message

mixed

$extra

array\Traversable

Exceptions

\Zend\Log\Exception\InvalidArgumentException if message can't be cast to string
\Zend\Log\Exception\InvalidArgumentException if extra can't be iterated over
\Zend\Log\Exception\RuntimeException if no log writer specified

Returns

\Zend\Log\Logger

notice()

notice(string $message, array|\Traversable $extra = array()) : \Zend\Log\Logger
inherited_from \Zend\Log\LoggerInterface::notice()

Parameters

$message

string

$extra

array\Traversable

Returns

\Zend\Log\Logger

Get processor instance

processorPlugin(string $name, array|null $options = null) : \Zend\Log\Processor\ProcessorInterface

Parameters

$name

string

$options

arraynull

Returns

\Zend\Log\Processor\ProcessorInterface

Register logging system as an error handler to log PHP errors

registerErrorHandler(\Zend\Log\Logger $logger, boolean $continueNativeHandler = false) : mixed
Static
link http://www.php.net/manual/function.set-error-handler.php

Parameters

$logger

\Zend\Log\Logger

$continueNativeHandler

boolean

Exceptions

\Zend\Log\Exception\InvalidArgumentException if logger is null

Returns

mixedReturns result of set_error_handler

Register logging system as an exception handler to log PHP exceptions

registerExceptionHandler(\Zend\Log\Logger $logger) : boolean
Static
link http://www.php.net/manual/en/function.set-exception-handler.php

Parameters

$logger

\Zend\Log\Logger

Exceptions

\Zend\Log\Exception\InvalidArgumentException if logger is null

Returns

boolean

Register a shutdown handler to log fatal errors

registerFatalErrorShutdownFunction(\Zend\Log\Logger $logger) : boolean
Static
link http://www.php.net/manual/function.register-shutdown-function.php

Parameters

$logger

\Zend\Log\Logger

Returns

boolean

Set processor plugin manager

setProcessorPluginManager(string|\Zend\Log\ProcessorPluginManager $plugins) : \Zend\Log\Logger

Parameters

$plugins

string\Zend\Log\ProcessorPluginManager

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Returns

\Zend\Log\Logger

Set writer plugin manager

setWriterPluginManager(string|\Zend\Log\WriterPluginManager $plugins) : \Zend\Log\Logger

Parameters

$plugins

string\Zend\Log\WriterPluginManager

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Returns

\Zend\Log\Logger

Set the writers

setWriters(\Zend\Stdlib\SplPriorityQueue $writers) : \Zend\Log\Logger

Parameters

$writers

\Zend\Stdlib\SplPriorityQueue

Exceptions

\Zend\Log\Exception\InvalidArgumentException

Returns

\Zend\Log\Logger

Unregister error handler

unregisterErrorHandler() 
Static

Unregister exception handler

unregisterExceptionHandler() 
Static

warn()

warn(string $message, array|\Traversable $extra = array()) : \Zend\Log\Logger
inherited_from \Zend\Log\LoggerInterface::warn()

Parameters

$message

string

$extra

array\Traversable

Returns

\Zend\Log\Logger

Get writer instance

writerPlugin(string $name, array|null $options = null) : \Zend\Log\Writer\WriterInterface

Parameters

$name

string

$options

arraynull

Returns

\Zend\Log\Writer\WriterInterface

 Properties

 

Map native PHP errors to priority

$errorPriorityMap : array

Default

array(E_NOTICE => self::NOTICE, E_USER_NOTICE => self::NOTICE, E_WARNING => self::WARN, E_CORE_WARNING => self::WARN, E_USER_WARNING => self::WARN, E_ERROR => self::ERR, E_USER_ERROR => self::ERR, E_CORE_ERROR => self::ERR, E_RECOVERABLE_ERROR => self::ERR, E_PARSE => self::ERR, E_COMPILE_ERROR => self::ERR, E_COMPILE_WARNING => self::ERR, E_STRICT => self::DEBUG, E_DEPRECATED => self::DEBUG, E_USER_DEPRECATED => self::DEBUG)
Static
 

List of priority code => priority (short) name

$priorities : array

Default

array(self::EMERG => 'EMERG', self::ALERT => 'ALERT', self::CRIT => 'CRIT', self::ERR => 'ERR', self::WARN => 'WARN', self::NOTICE => 'NOTICE', self::INFO => 'INFO', self::DEBUG => 'DEBUG')
 

Processor plugins

$processorPlugins : \Zend\Log\ProcessorPluginManager

Default

 

Processors

$processors : \Zend\Stdlib\SplPriorityQueue

Default

 

Registered error handler

$registeredErrorHandler : boolean

Default

false
Static
 

Registered exception handler

$registeredExceptionHandler : boolean

Default

false
Static
 

Registered shutdown error handler

$registeredFatalErrorShutdownFunction : boolean

Default

false
Static
 

Writer plugins

$writerPlugins : \Zend\Log\WriterPluginManager

Default

 

Writers

$writers : \Zend\Stdlib\SplPriorityQueue

Default

 Constants

 

ALERT

ALERT = 1 
 

CRIT

CRIT = 2 
 

DEBUG

DEBUG = 7 
 

EMERG

EMERG = 0 
const int defined from the BSD Syslog message severities
link http://tools.ietf.org/html/rfc3164
 

ERR

ERR = 3 
 

INFO

INFO = 6 
 

NOTICE

NOTICE = 5 
 

WARN

WARN = 4