phpDocumentor Log
[ class tree: Log ] [ index: Log ] [ all elements ]

Class: Log

Source Location: /lodel/scripts/PEAR/Log.php

Class Log

Class Overview

The Log:: class implements both an abstraction for various logging mechanisms and the Subject end of a Subject-Observer pattern.

Located in /lodel/scripts/PEAR/Log.php [line 37]



		
				Author(s):
		
		
		
Information Tags:
Since:  Horde 1.3

Properties

Methods

[ Top ]
Descendants
Child Class Description
Log_file The Log_file class is a concrete implementation of the Log abstract class that logs messages to a text file.

[ Top ]
Property Summary
array   $_formatMap   Maps canonical format keys to position arguments for use in building "line format" strings.
integer   $_id   Instance-specific unique identification number.
string   $_ident   The label that uniquely identifies this set of log messages.
array   $_listeners   Holds all Log_observer objects that wish to be notified of new messages.
integer   $_mask   The bitmask of allowed log levels.
boolean   $_opened   Indicates whether or not the log can been opened / connected.
integer   $_priority   The default priority to use when logging an event.

[ Top ]
Method Summary
boolean   alert()   A convenience function for logging an alert event. It will log a message at the PEAR_LOG_ALERT log level.
void   attach()   Adds a Log_observer instance to the list of observers that are listening for messages emitted by this Log instance.
void   close()   Abstract implementation of the close() method.
boolean   crit()   A convenience function for logging a critical event. It will log a message at the PEAR_LOG_CRIT log level.
boolean   debug()   A convenience function for logging a debug event. It will log a message at the PEAR_LOG_DEBUG log level.
void   detach()   Removes a Log_observer instance from the list of observers.
boolean   emerg()   A convenience function for logging a emergency event. It will log a message at the PEAR_LOG_EMERG log level.
boolean   err()   A convenience function for logging a error event. It will log a message at the PEAR_LOG_ERR log level.
object Log   &factory()   Attempts to return a concrete Log instance of type $handler.
void   flush()   Abstract implementation of the flush() method.
string   getIdent()   Returns the current identification string.
interger   getMask()   Returns the current level mask.
integer   getPriority()   Returns the current default priority.
boolean   info()   A convenience function for logging a information event. It will log a message at the PEAR_LOG_INFO log level.
boolean   isComposite()   Indicates whether this is a composite class.
void   log()   Abstract implementation of the log() method.
integer   MASK()   Calculate the log mask for the given priority.
integer   MAX()   Calculate the log mask for all priorities less than or equal to the given priority. In other words, $priority will be the highests priority matched by the resulting mask.
integer   MIN()   Calculate the log mask for all priorities greater than or equal to the given priority. In other words, $priority will be the lowest priority matched by the resulting mask.
boolean   notice()   A convenience function for logging a notice event. It will log a message at the PEAR_LOG_NOTICE log level.
void   open()   Abstract implementation of the open() method.
string   priorityToString()   Returns the string representation of a PEAR_LOG_* integer constant.
void   setIdent()   Sets this Log instance's identification string.
integer   setMask()   Set and return the level mask for the current Log instance.
void   setPriority()   Sets the default priority to the specified value.
object Log   &singleton()   Attempts to return a reference to a concrete Log instance of type $handler, only creating a new instance if no log instance with the same parameters currently exists.
string   stringToPriority()   Returns the the PEAR_LOG_* integer constant for the given string representation of a priority name. This function performs a case-insensitive search.
integer   UPTO()   Calculate the log mask for all priorities up to the given priority.
boolean   warning()   A convenience function for logging a warning event. It will log a message at the PEAR_LOG_WARNING log level.
void   _announce()   Informs each registered observer instance that a new message has been logged.
string   _extractMessage()   Returns the string representation of the message data.
string   _format()   Produces a formatted log line based on a format string and a set of variables representing the current log record and state.
array   _getBacktraceVars()   Using debug_backtrace(), returns the file, line, and enclosing function name of the source code context from which log() was invoked.
boolean   _isMasked()   Check if the given priority is included in the current level mask.

[ Top ]
Properties
array   $_formatMap = array('%{timestamp}' => '%1$s',
'%{ident}' => '%2$s',
'%{priority}' => '%3$s',
'%{message}' => '%4$s',
'%{file}' => '%5$s',
'%{line}' => '%6$s',
'%{function}' => '%7$s',
'%\{' => '%%{')
[line 94]

Maps canonical format keys to position arguments for use in building "line format" strings.

API Tags:
Access:  private


[ Top ]
integer   $_id = 0 [line 53]

Instance-specific unique identification number.

API Tags:
Access:  private


[ Top ]
string   $_ident = '' [line 61]

The label that uniquely identifies this set of log messages.

API Tags:
Access:  private


[ Top ]
array   $_listeners = array() [line 85]

Holds all Log_observer objects that wish to be notified of new messages.

API Tags:
Access:  private


[ Top ]
integer   $_mask = PEAR_LOG_ALL [line 77]

The bitmask of allowed log levels.

API Tags:
Access:  private


[ Top ]
boolean   $_opened = false [line 45]

Indicates whether or not the log can been opened / connected.

API Tags:
Access:  private


[ Top ]
integer   $_priority = PEAR_LOG_INFO [line 69]

The default priority to use when logging an event.

API Tags:
Access:  private


[ Top ]
Methods
alert  [line 271]

  boolean alert( mixed $message  )

A convenience function for logging an alert event. It will log a message at the PEAR_LOG_ALERT log level.

Parameters:
mixed   $message:  String or object containing the message to log.

API Tags:
Return:  True if the message was successfully logged.
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
attach  [line 735]

  void attach( &$observer, object $observer, boolean 1  )

Adds a Log_observer instance to the list of observers that are listening for messages emitted by this Log instance.

Parameters:
object   $observer:  The Log_observer instance to attach as a listener.
boolean   1:  True if the observer is successfully attached.
   &$observer: 

API Tags:
Access:  public

Information Tags:
Since:  Log 1.0

[ Top ]
close  [line 219]

  void close( )

Abstract implementation of the close() method.


Information Tags:
Since:  Log 1.0

Redefined in descendants as:

[ Top ]
crit  [line 288]

  boolean crit( mixed $message  )

A convenience function for logging a critical event. It will log a message at the PEAR_LOG_CRIT log level.

Parameters:
mixed   $message:  String or object containing the message to log.

API Tags:
Return:  True if the message was successfully logged.
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
debug  [line 373]

  boolean debug( mixed $message  )

A convenience function for logging a debug event. It will log a message at the PEAR_LOG_DEBUG log level.

Parameters:
mixed   $message:  String or object containing the message to log.

API Tags:
Return:  True if the message was successfully logged.
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
detach  [line 757]

  void detach( object $observer, boolean 1  )

Removes a Log_observer instance from the list of observers.

Parameters:
object   $observer:  The Log_observer instance to detach from the list of listeners.
boolean   1:  True if the observer is successfully detached.

API Tags:
Access:  public

Information Tags:
Since:  Log 1.0

[ Top ]
emerg  [line 254]

  boolean emerg( mixed $message  )

A convenience function for logging a emergency event. It will log a message at the PEAR_LOG_EMERG log level.

Parameters:
mixed   $message:  String or object containing the message to log.

API Tags:
Return:  True if the message was successfully logged.
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
err  [line 305]

  boolean err( mixed $message  )

A convenience function for logging a error event. It will log a message at the PEAR_LOG_ERR log level.

Parameters:
mixed   $message:  String or object containing the message to log.

API Tags:
Return:  True if the message was successfully logged.
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
factory  [line 129]

  object Log &factory( string $handler, [string $name = ''], [string $ident = ''], [array $conf = array()], [int $level = PEAR_LOG_DEBUG]  )

Attempts to return a concrete Log instance of type $handler.

Parameters:
string   $handler:  The type of concrete Log subclass to return. Attempt to dynamically include the code for this subclass. Currently, valid values are 'console', 'syslog', 'sql', 'file', and 'mcal'.
string   $name:  The name of the actually log file, table, or other specific store to use. Defaults to an empty string, with which the subclass will attempt to do something intelligent.
string   $ident:  The identity reported to the log system.
array   $conf:  A hash containing any additional configuration information that a subclass might need.
int   $level:  Log messages up to and including this level.

API Tags:
Return:  The newly created concrete Log instance, or null on an error.
Access:  public

Information Tags:
Since:  Log 1.0

[ Top ]
flush  [line 228]

  void flush( )

Abstract implementation of the flush() method.


Information Tags:
Since:  Log 1.8.2

Redefined in descendants as:

[ Top ]
getIdent  [line 820]

  string getIdent( )

Returns the current identification string.


API Tags:
Return:  The current Log instance's identification string.
Access:  public

Information Tags:
Since:  Log 1.6.3

[ Top ]
getMask  [line 676]

  interger getMask( )

Returns the current level mask.


API Tags:
Return:  The current level mask.
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
getPriority  [line 705]

  integer getPriority( )

Returns the current default priority.


API Tags:
Return:  The current default priority.
Access:  public

Information Tags:
Since:  Log 1.8.4

[ Top ]
info  [line 356]

  boolean info( mixed $message  )

A convenience function for logging a information event. It will log a message at the PEAR_LOG_INFO log level.

Parameters:
mixed   $message:  String or object containing the message to log.

API Tags:
Return:  True if the message was successfully logged.
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
isComposite  [line 794]

  boolean isComposite( )

Indicates whether this is a composite class.


API Tags:
Return:  True if this is a composite class.
Access:  public

Information Tags:
Since:  Log 1.0

[ Top ]
log  [line 237]

  void log( $message, [ $priority = null]  )

Abstract implementation of the log() method.

Parameters:
   $message: 
   $priority: 

Information Tags:
Since:  Log 1.0

Redefined in descendants as:
  • Log_file::log() : Logs $message to the output window. The message is also passed along to any Log_observer instances that are observing this Log.

[ Top ]
MASK  [line 589]

  integer MASK( integer $priority  )

Calculate the log mask for the given priority.

This method may be called statically.

Parameters:
integer   $priority:  The priority whose mask will be calculated.

API Tags:
Return:  The calculated log mask.
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
MAX  [line 646]

  integer MAX( integer $priority  )

Calculate the log mask for all priorities less than or equal to the given priority. In other words, $priority will be the highests priority matched by the resulting mask.

This method may be called statically.

Parameters:
integer   $priority:  The maximum priority covered by this mask.

API Tags:
Return:  The resulting log mask.
Access:  public

Information Tags:
Since:  Log 1.9.4

[ Top ]
MIN  [line 627]

  integer MIN( integer $priority  )

Calculate the log mask for all priorities greater than or equal to the given priority. In other words, $priority will be the lowest priority matched by the resulting mask.

This method may be called statically.

Parameters:
integer   $priority:  The minimum priority covered by this mask.

API Tags:
Return:  The resulting log mask.
Access:  public

Information Tags:
Since:  Log 1.9.4

[ Top ]
notice  [line 339]

  boolean notice( mixed $message  )

A convenience function for logging a notice event. It will log a message at the PEAR_LOG_NOTICE log level.

Parameters:
mixed   $message:  String or object containing the message to log.

API Tags:
Return:  True if the message was successfully logged.
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
open  [line 210]

  void open( )

Abstract implementation of the open() method.


Information Tags:
Since:  Log 1.0

Redefined in descendants as:
  • Log_file::open() : Opens the log file for output. If the specified log file does not already exist, it will be created. By default, new log entries are appended to the end of the log file.

[ Top ]
priorityToString  [line 533]

  string priorityToString( int $priority  )

Returns the string representation of a PEAR_LOG_* integer constant.

Parameters:
int   $priority:  A PEAR_LOG_* integer constant.

API Tags:
Return:  The string representation of $level.

Information Tags:
Since:  Log 1.0

[ Top ]
setIdent  [line 807]

  void setIdent( string $ident  )

Sets this Log instance's identification string.

Parameters:
string   $ident:  The new identification string.

API Tags:
Access:  public

Information Tags:
Since:  Log 1.6.3

[ Top ]
setMask  [line 661]

  integer setMask( integer $mask  )

Set and return the level mask for the current Log instance.

Parameters:
integer   $mask:  A bitwise mask of log levels.

API Tags:
Return:  The current level mask.
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
setPriority  [line 718]

  void setPriority( integer $priority  )

Sets the default priority to the specified value.

Parameters:
integer   $priority:  The new default priority.

API Tags:
Access:  public

Information Tags:
Since:  Log 1.8.4

[ Top ]
singleton  [line 191]

  object Log &singleton( string $handler, [string $name = ''], [string $ident = ''], [array $conf = array()], [int $level = PEAR_LOG_DEBUG]  )

Attempts to return a reference to a concrete Log instance of type $handler, only creating a new instance if no log instance with the same parameters currently exists.

You should use this if there are multiple places you might create a logger, you don't want to create multiple loggers, and you don't want to check for the existance of one each time. The singleton pattern does all the checking work for you.

You MUST call this method with the $var = &Log::singleton() syntax. Without the ampersand (&) in front of the method name, you will not get a reference, you will get a copy.

Parameters:
string   $handler:  The type of concrete Log subclass to return. Attempt to dynamically include the code for this subclass. Currently, valid values are 'console', 'syslog', 'sql', 'file', and 'mcal'.
string   $name:  The name of the actually log file, table, or other specific store to use. Defaults to an empty string, with which the subclass will attempt to do something intelligent.
string   $ident:  The identity reported to the log system.
array   $conf:  A hash containing any additional configuration information that a subclass might need.
int   $level:  Log messages up to and including this level.

API Tags:
Return:  The newly created concrete Log instance, or null on an error.
Access:  public

Information Tags:
Since:  Log 1.0

[ Top ]
stringToPriority  [line 561]

  string stringToPriority( string $name  )

Returns the the PEAR_LOG_* integer constant for the given string representation of a priority name. This function performs a case-insensitive search.

Parameters:
string   $name:  String containing a priority name.

API Tags:
Return:  The PEAR_LOG_* integer contstant corresponding the the specified priority name.

Information Tags:
Since:  Log 1.9.0

[ Top ]
UPTO  [line 608]

  integer UPTO( integer $priority  )

Calculate the log mask for all priorities up to the given priority.

This method may be called statically.

Parameters:
integer   $priority:  The maximum priority covered by this mask.

API Tags:
Return:  The resulting log mask.
Deprecated:  deprecated since Log 1.9.4; use Log::MAX() instead
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
warning  [line 322]

  boolean warning( mixed $message  )

A convenience function for logging a warning event. It will log a message at the PEAR_LOG_WARNING log level.

Parameters:
mixed   $message:  String or object containing the message to log.

API Tags:
Return:  True if the message was successfully logged.
Access:  public

Information Tags:
Since:  Log 1.7.0

[ Top ]
_announce  [line 777]

  void _announce( array $event  )

Informs each registered observer instance that a new message has been logged.

Parameters:
array   $event:  A hash describing the log event.

API Tags:
Access:  private


[ Top ]
_extractMessage  [line 395]

  string _extractMessage( mixed $message  )

Returns the string representation of the message data.

If $message is an object, _extractMessage() will attempt to extract the message text using a known method (such as a PEAR_Error object's getMessage() method). If a known method, cannot be found, the serialized representation of the object will be returned.

If the message data is already a string, it will be returned unchanged.

Parameters:
mixed   $message:  The original message data. This may be a string or any object.

API Tags:
Return:  The string representation of the message.
Access:  private


[ Top ]
_format  [line 499]

  string _format( $format, $timestamp, $priority, $message  )

Produces a formatted log line based on a format string and a set of variables representing the current log record and state.

Parameters:
   $format: 
   $timestamp: 
   $priority: 
   $message: 

API Tags:
Return:  Formatted log string.
Access:  private

Information Tags:
Since:  Log 1.9.4

[ Top ]
_getBacktraceVars  [line 443]

  array _getBacktraceVars( int $depth  )

Using debug_backtrace(), returns the file, line, and enclosing function name of the source code context from which log() was invoked.

Parameters:
int   $depth:  The initial number of frames we should step back into the trace.

API Tags:
Return:  Array containing three strings: the filename, the line, and the function name from which log() was called.
Access:  private

Information Tags:
Since:  Log 1.9.4

[ Top ]
_isMasked  [line 692]

  boolean _isMasked( integer $priority  )

Check if the given priority is included in the current level mask.

Parameters:
integer   $priority:  The priority to check.

API Tags:
Return:  True if the given priority is included in the current log mask.
Access:  private

Information Tags:
Since:  Log 1.7.0

[ Top ]

Documentation generated on Tue, 17 Jun 2008 05:07:52 +0200 by phpDocumentor 1.4.0a2