Zend Framework  3.0
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Attributes | Static Protected Attributes | List of all members
Logger Class Reference

Logging messages with a stack of backends. More...

Public Member Functions

 __construct ($options=null)
 Constructor.
 
 __destruct ()
 Shutdown all writers.
 
 getWriterPluginManager ()
 Get writer plugin manager.
 
 setWriterPluginManager (WriterPluginManager $writerPlugins)
 Set writer plugin manager.
 
 writerPlugin ($name, array $options=null)
 Get writer instance.
 
 addWriter ($writer, $priority=1, array $options=null)
 Add a writer to a logger.
 
 getWriters ()
 Get writers.
 
 setWriters (SplPriorityQueue $writers)
 Set the writers.
 
 getProcessorPluginManager ()
 Get processor plugin manager.
 
 setProcessorPluginManager ($plugins)
 Set processor plugin manager.
 
 processorPlugin ($name, array $options=null)
 Get processor instance.
 
 addProcessor ($processor, $priority=1, array $options=null)
 Add a processor to a logger.
 
 getProcessors ()
 Get processors.
 
 log ($priority, $message, $extra=[])
 Add a message as a log entry.
 
 emerg ($message, $extra=[])
 
 alert ($message, $extra=[])
 
 crit ($message, $extra=[])
 
 err ($message, $extra=[])
 
 warn ($message, $extra=[])
 
 notice ($message, $extra=[])
 
 info ($message, $extra=[])
 
 debug ($message, $extra=[])
 

Static Public Member Functions

static registerErrorHandler (Logger $logger, $continueNativeHandler=false)
 Register logging system as an error handler to log PHP errors.
 
static unregisterErrorHandler ()
 Unregister error handler.
 
static registerFatalErrorShutdownFunction (Logger $logger)
 Register a shutdown handler to log fatal errors.
 
static registerExceptionHandler (Logger $logger)
 Register logging system as an exception handler to log PHP exceptions.
 
static unregisterExceptionHandler ()
 Unregister exception handler.
 

Public Attributes

const EMERG = 0
 int defined from the BSD Syslog message severities http://tools.ietf.org/html/rfc3164
 
const ALERT = 1
 
const CRIT = 2
 
const ERR = 3
 
const WARN = 4
 
const NOTICE = 5
 
const INFO = 6
 
const DEBUG = 7
 

Static Public Attributes

static $errorPriorityMap
 
static E_USER_NOTICE
 

Protected Attributes

 $priorities
 
 $writers
 
 $processors
 
 $writerPlugins
 
 $processorPlugins
 

Static Protected Attributes

static $registeredErrorHandler = false
 
static $registeredFatalErrorShutdownFunction = false
 
static $registeredExceptionHandler = false
 

Detailed Description

Logging messages with a stack of backends.

Constructor & Destructor Documentation

__construct (   $options = null)

Constructor.

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
array | Traversable$options
Returns
Logger
Exceptions
Exception\InvalidArgumentException
__destruct ( )

Shutdown all writers.

Returns
void

Member Function Documentation

addProcessor (   $processor,
  $priority = 1,
array  $options = null 
)

Add a processor to a logger.

Parameters
string | Processor\ProcessorInterface$processor
int$priority
array | null$options
Returns
Logger
Exceptions
Exception\InvalidArgumentException
addWriter (   $writer,
  $priority = 1,
array  $options = null 
)

Add a writer to a logger.

Parameters
string | Writer\WriterInterface$writer
int$priority
array | null$options
Returns
Logger
Exceptions
Exception\InvalidArgumentException
alert (   $message,
  $extra = [] 
)
Parameters
string$message
array | Traversable$extra
Returns
Logger

Implements LoggerInterface.

crit (   $message,
  $extra = [] 
)
Parameters
string$message
array | Traversable$extra
Returns
Logger

Implements LoggerInterface.

debug (   $message,
  $extra = [] 
)
Parameters
string$message
array | Traversable$extra
Returns
Logger

Implements LoggerInterface.

emerg (   $message,
  $extra = [] 
)
Parameters
string$message
array | Traversable$extra
Returns
Logger

Implements LoggerInterface.

err (   $message,
  $extra = [] 
)
Parameters
string$message
array | Traversable$extra
Returns
Logger

Implements LoggerInterface.

getProcessorPluginManager ( )

Get processor plugin manager.

Returns
ProcessorPluginManager
getProcessors ( )

Get processors.

Returns
SplPriorityQueue
getWriterPluginManager ( )

Get writer plugin manager.

Returns
WriterPluginManager
getWriters ( )

Get writers.

Returns
SplPriorityQueue
info (   $message,
  $extra = [] 
)
Parameters
string$message
array | Traversable$extra
Returns
Logger

Implements LoggerInterface.

log (   $priority,
  $message,
  $extra = [] 
)

Add a message as a log entry.

Parameters
int$priority
mixed$message
array | Traversable$extra
Returns
Logger
Exceptions
Exception\InvalidArgumentExceptionif message can't be cast to string
Exception\InvalidArgumentExceptionif extra can't be iterated over
Exception\RuntimeExceptionif no log writer specified
notice (   $message,
  $extra = [] 
)
Parameters
string$message
array | Traversable$extra
Returns
Logger

Implements LoggerInterface.

processorPlugin (   $name,
array  $options = null 
)

Get processor instance.

Parameters
string$name
array | null$options
Returns
Processor
static registerErrorHandler ( Logger  $logger,
  $continueNativeHandler = false 
)
static
static registerExceptionHandler ( Logger  $logger)
static

Register logging system as an exception handler to log PHP exceptions.

Logger $logger bool Exception if logger is null

static registerFatalErrorShutdownFunction ( Logger  $logger)
static

Register a shutdown handler to log fatal errors.

Logger $logger bool

setProcessorPluginManager (   $plugins)

Set processor plugin manager.

Parameters
string | ProcessorPluginManager$plugins
Returns
Logger
Exceptions
Exception\InvalidArgumentException
setWriterPluginManager ( WriterPluginManager  $writerPlugins)

Set writer plugin manager.

Parameters
WriterPluginManager$writerPlugins
Returns
Logger
setWriters ( SplPriorityQueue  $writers)

Set the writers.

Parameters
SplPriorityQueue$writers
Returns
Logger
Exceptions
Exception\InvalidArgumentException
static unregisterErrorHandler ( )
static

Unregister error handler.

static unregisterExceptionHandler ( )
static

Unregister exception handler.

warn (   $message,
  $extra = [] 
)
Parameters
string$message
array | Traversable$extra
Returns
Logger

Implements LoggerInterface.

writerPlugin (   $name,
array  $options = null 
)

Get writer instance.

Parameters
string$name
array | null$options
Returns
Writer

Member Data Documentation

$errorPriorityMap
static
Initial value:
= [
E_NOTICE => self::NOTICE
$priorities
protected
Initial value:
= [
self::EMERG => 'EMERG'
$processorPlugins
protected
$processors
protected
$registeredErrorHandler = false
staticprotected
$registeredExceptionHandler = false
staticprotected
$registeredFatalErrorShutdownFunction = false
staticprotected
$writerPlugins
protected
$writers
protected
const ALERT = 1
const CRIT = 2
const DEBUG = 7
E_USER_NOTICE
static
Initial value:
=> 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,
]
const EMERG = 0

int defined from the BSD Syslog message severities http://tools.ietf.org/html/rfc3164

const ERR = 3
const INFO = 6
const NOTICE = 5
const WARN = 4