Zend Framework  1.12
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Zend_Log Class Reference

Public Member Functions

 __construct (Zend_Log_Writer_Abstract $writer=null)
 Class constructor.
 
 __destruct ()
 Class destructor.
 
 __call ($method, $params)
 Undefined method handler allows a shortcut: $log->priorityName('message') instead of $log->log('message', Zend_Log::PRIORITY_NAME)
 
 log ($message, $priority, $extras=null)
 Log a message at a priority.
 
 addPriority ($name, $priority)
 Add a custom priority.
 
 addFilter ($filter)
 Add a filter that will be applied before all log writers.
 
 addWriter ($writer)
 Add a writer.
 
 setEventItem ($name, $value)
 Set an extra item to pass to the log writers.
 
 registerErrorHandler ()
 Register Logging system as an error handler to log php errors Note: it still calls the original error handler if set_error_handler is able to return it.
 
 errorHandler ($errno, $errstr, $errfile, $errline, $errcontext)
 Error Handler will convert error into log message, and then call the original error handler.
 
 setTimestampFormat ($format)
 Set timestamp format for log entries.
 
 getTimestampFormat ()
 Get timestamp format used for log entries.
 

Static Public Member Functions

static factory ($config=array())
 Factory to construct the logger and one or more writers based on the configuration array.
 

Public Attributes

const EMERG = 0
 
const ALERT = 1
 
const CRIT = 2
 
const ERR = 3
 
const WARN = 4
 
const NOTICE = 5
 
const INFO = 6
 
const DEBUG = 7
 

Protected Member Functions

 _constructWriterFromConfig ($config)
 Construct a writer object based on a configuration array.
 
 _constructFilterFromConfig ($config)
 Construct filter object from configuration array or Zend_Config object.
 
 _constructFormatterFromConfig ($config)
 Construct formatter object from configuration array or Zend_Config object.
 
 _constructFromConfig ($type, $config, $namespace)
 Construct a filter or writer from config.
 
 getClassName ($config, $type, $defaultNamespace)
 Get the writer or filter full classname.
 
 _packEvent ($message, $priority)
 Packs message and priority into Event array.
 

Protected Attributes

 $_priorities = array()
 
 $_writers = array()
 
 $_filters = array()
 
 $_extras = array()
 
 $_defaultWriterNamespace = 'Zend_Log_Writer'
 
 $_defaultFilterNamespace = 'Zend_Log_Filter'
 
 $_defaultFormatterNamespace = 'Zend_Log_Formatter'
 
 $_origErrorHandler = null
 
 $_registeredErrorHandler = false
 
 $_errorHandlerMap = false
 
 $_timestampFormat = 'c'
 

Constructor & Destructor Documentation

__construct ( Zend_Log_Writer_Abstract  $writer = null)

Class constructor.

Create a new logger

Parameters
Zend_Log_Writer_Abstract | null$writerdefault writer
Returns
void
__destruct ( )

Class destructor.

Shutdown log writers

Returns
void

Member Function Documentation

__call (   $method,
  $params 
)

Undefined method handler allows a shortcut: $log->priorityName('message') instead of $log->log('message', Zend_Log::PRIORITY_NAME)

Parameters
string$methodpriority name
string$paramsmessage to log
Returns
void
Exceptions
Zend_Log_Exception
See Also
Zend_Log_Exception
Zend_Log_Exception
_constructFilterFromConfig (   $config)
protected

Construct filter object from configuration array or Zend_Config object.

Parameters
array | Zend_Config$configZend_Config or Array
Returns
Zend_Log_Filter_Interface
Exceptions
Zend_Log_Exception
See Also
Zend_Log_Exception
_constructFormatterFromConfig (   $config)
protected

Construct formatter object from configuration array or Zend_Config object.

Parameters
array | Zend_Config$configZend_Config or Array
Returns
Zend_Log_Formatter_Interface
Exceptions
Zend_Log_Exception
See Also
Zend_Log_Exception
_constructFromConfig (   $type,
  $config,
  $namespace 
)
protected

Construct a filter or writer from config.

Parameters
string$type'writer' of 'filter'
mixed$configZend_Config or Array
string$namespace
Returns
object
Exceptions
Zend_Log_Exception
_constructWriterFromConfig (   $config)
protected

Construct a writer object based on a configuration array.

Parameters
array$specconfig array with writer spec
Returns
Zend_Log_Writer_Abstract
Exceptions
Zend_Log_Exception
See Also
Zend_Log_Exception
_packEvent (   $message,
  $priority 
)
protected

Packs message and priority into Event array.

Parameters
string$messageMessage to log
integer$priorityPriority of message
Returns
array Event array
addFilter (   $filter)

Add a filter that will be applied before all log writers.

Before a message will be received by any of the writers, it must be accepted by all filters added with this method.

Parameters
int | Zend_Config | array | Zend_Log_Filter_Interface$filter
Returns
Zend_Log
Exceptions
Zend_Log_Exception
See Also
Zend_Log_Filter_Priority
Zend_Log_Exception
addPriority (   $name,
  $priority 
)

Add a custom priority.

Parameters
string$nameName of priority
integer$priorityNumeric priority
Exceptions
Zend_Log_Exception
See Also
Zend_Log_Exception
addWriter (   $writer)

Add a writer.

A writer is responsible for taking a log message and writing it out to storage.

Parameters
mixed$writerZend_Log_Writer_Abstract or Config array
Returns
Zend_Log
See Also
Zend_Log_Exception
errorHandler (   $errno,
  $errstr,
  $errfile,
  $errline,
  $errcontext 
)

Error Handler will convert error into log message, and then call the original error handler.

Custom error handler int $errno string $errstr string $errfile int $errline array $errcontext boolean

static factory (   $config = array())
static

Factory to construct the logger and one or more writers based on the configuration array.

Parameters
array|Zend_ConfigArray or instance of Zend_Config
Returns
Zend_Log
Exceptions
Zend_Log_Exception
See Also
Zend_Log_Exception
Zend_Log_Exception
getClassName (   $config,
  $type,
  $defaultNamespace 
)
protected

Get the writer or filter full classname.

Parameters
array$config
string$typefilter|writer
string$defaultNamespace
Returns
string full classname
Exceptions
Zend_Log_Exception
getTimestampFormat ( )

Get timestamp format used for log entries.

Returns
string
log (   $message,
  $priority,
  $extras = null 
)

Log a message at a priority.

Parameters
string$messageMessage to log
integer$priorityPriority of message
mixed$extrasExtra information to log in event
Returns
void
Exceptions
Zend_Log_Exception
See Also
Zend_Log_Exception
Zend_Log_Exception
registerErrorHandler ( )

Register Logging system as an error handler to log php errors Note: it still calls the original error handler if set_error_handler is able to return it.

Errors will be mapped as: E_NOTICE, E_USER_NOTICE => NOTICE E_WARNING, E_CORE_WARNING, E_USER_WARNING => WARN E_ERROR, E_USER_ERROR, E_CORE_ERROR, E_RECOVERABLE_ERROR => ERR E_DEPRECATED, E_STRICT, E_USER_DEPRECATED => DEBUG (unknown/other) => INFO

Custom error handler Zend_Log

setEventItem (   $name,
  $value 
)

Set an extra item to pass to the log writers.

Parameters
string$nameName of the field
string$valueValue of the field
Returns
Zend_Log
setTimestampFormat (   $format)

Set timestamp format for log entries.

Parameters
string$format
Returns
Zend_Log

Member Data Documentation

$_defaultFilterNamespace = 'Zend_Log_Filter'
protected
$_defaultFormatterNamespace = 'Zend_Log_Formatter'
protected
$_defaultWriterNamespace = 'Zend_Log_Writer'
protected
$_errorHandlerMap = false
protected
$_extras = array()
protected
$_filters = array()
protected
$_origErrorHandler = null
protected
$_priorities = array()
protected
$_registeredErrorHandler = false
protected
$_timestampFormat = 'c'
protected
$_writers = array()
protected
const ALERT = 1
const CRIT = 2
const DEBUG = 7
const EMERG = 0
const ERR = 3
const INFO = 6
const NOTICE = 5
const WARN = 4