ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
Log_daemon Class Reference
+ Inheritance diagram for Log_daemon:
+ Collaboration diagram for Log_daemon:

Public Member Functions

 Log_daemon ($name, $ident= '', $conf=array(), $level=PEAR_LOG_DEBUG)
 Constructs a new syslog object.
 _Log_daemon ()
 Destructor.
 open ()
 Opens a connection to the system logger, if it has not already been opened.
 close ()
 Closes the connection to the system logger, if it is open.
 log ($message, $priority=null)
 Sends $message to the currently open syslog connection.
 _toSyslog ($priority)
 Converts a PEAR_LOG_* constant into a syslog LOG_* constant.
- Public Member Functions inherited from Log
 _classExists ($class)
 Utility function which wraps PHP's class_exists() function to ensure consistent behavior between PHP versions 4 and 5.
factory ($handler, $name= '', $ident= '', $conf=array(), $level=PEAR_LOG_DEBUG)
 Attempts to return a concrete Log instance of type $handler.
singleton ($handler, $name= '', $ident= '', $conf=array(), $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.
 flush ()
 Abstract implementation of the flush() method.
 emerg ($message)
 A convenience function for logging a emergency event.
 alert ($message)
 A convenience function for logging an alert event.
 crit ($message)
 A convenience function for logging a critical event.
 err ($message)
 A convenience function for logging a error event.
 warning ($message)
 A convenience function for logging a warning event.
 notice ($message)
 A convenience function for logging a notice event.
 info ($message)
 A convenience function for logging a information event.
 debug ($message)
 A convenience function for logging a debug event.
 _extractMessage ($message)
 Returns the string representation of the message data.
 _getBacktraceVars ($depth)
 Using debug_backtrace(), returns the file, line, and enclosing function name of the source code context from which log() was invoked.
 _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.
 priorityToString ($priority)
 Returns the string representation of a PEAR_LOG_* integer constant.
 stringToPriority ($name)
 Returns the the PEAR_LOG_* integer constant for the given string representation of a priority name.
 MASK ($priority)
 Calculate the log mask for the given priority.
 UPTO ($priority)
 Calculate the log mask for all priorities up to the given priority.
 MIN ($priority)
 Calculate the log mask for all priorities greater than or equal to the given priority.
 MAX ($priority)
 Calculate the log mask for all priorities less than or equal to the given priority.
 setMask ($mask)
 Set and return the level mask for the current Log instance.
 getMask ()
 Returns the current level mask.
 _isMasked ($priority)
 Check if the given priority is included in the current level mask.
 getPriority ()
 Returns the current default priority.
 setPriority ($priority)
 Sets the default priority to the specified value.
 attach (&$observer)
 Adds a Log_observer instance to the list of observers that are listening for messages emitted by this Log instance.
 detach ($observer)
 Removes a Log_observer instance from the list of observers.
 _announce ($event)
 Informs each registered observer instance that a new message has been logged.
 isComposite ()
 Indicates whether this is a composite class.
 setIdent ($ident)
 Sets this Log instance's identification string.
 getIdent ()
 Returns the current identification string.

Data Fields

 $_name = LOG_DAEMON
 $_socket
 $_ip = '127.0.0.1'
 $_proto = 'udp'
 $_port = 514
 $_maxsize = 4096
 $_timeout = 1
- Data Fields inherited from Log
 $_opened = false
 $_id = 0
 $_ident = ''
 $_priority = PEAR_LOG_INFO
 $_mask = PEAR_LOG_ALL
 $_listeners = array()
 $_formatMap

Detailed Description

Definition at line 18 of file daemon.php.

Member Function Documentation

Log_daemon::_Log_daemon ( )

Destructor.

private

Definition at line 112 of file daemon.php.

References close().

{
$this->close();
}

+ Here is the call graph for this function:

Log_daemon::_toSyslog (   $priority)

Converts a PEAR_LOG_* constant into a syslog LOG_* constant.

This function exists because, under Windows, not all of the LOG_* constants have unique values. Instead, the PEAR_LOG_* were introduced for global use, with the conversion to the LOG_* constants kept local to to the syslog driver.

Parameters
int$priorityPEAR_LOG_* value to convert to LOG_* value.
Returns
The LOG_* representation of $priority.

private

Definition at line 214 of file daemon.php.

References PEAR_LOG_ALERT, PEAR_LOG_CRIT, PEAR_LOG_DEBUG, PEAR_LOG_EMERG, PEAR_LOG_ERR, PEAR_LOG_INFO, PEAR_LOG_NOTICE, and PEAR_LOG_WARNING.

Referenced by log().

{
static $priorities = array(
PEAR_LOG_EMERG => LOG_EMERG,
PEAR_LOG_ALERT => LOG_ALERT,
PEAR_LOG_CRIT => LOG_CRIT,
PEAR_LOG_ERR => LOG_ERR,
PEAR_LOG_WARNING => LOG_WARNING,
PEAR_LOG_NOTICE => LOG_NOTICE,
PEAR_LOG_INFO => LOG_INFO,
PEAR_LOG_DEBUG => LOG_DEBUG
);
/* If we're passed an unknown priority, default to LOG_INFO. */
if (!is_int($priority) || !in_array($priority, $priorities)) {
return LOG_INFO;
}
return $priorities[$priority];
}

+ Here is the caller graph for this function:

Log_daemon::close ( )

Closes the connection to the system logger, if it is open.

public

Reimplemented from Log.

Definition at line 139 of file daemon.php.

Referenced by _Log_daemon().

{
if ($this->_opened) {
$this->_opened = false;
return fclose($this->_socket);
}
return true;
}

+ Here is the caller graph for this function:

Log_daemon::log (   $message,
  $priority = null 
)

Sends $message to the currently open syslog connection.

Calls open() if necessary. Also passes the message along to any Log_observer instances that are observing this Log.

Parameters
string$messageThe textual message to be logged.
int$priority(optional) The priority of the message. Valid values are: LOG_EMERG, LOG_ALERT, LOG_CRIT, LOG_ERR, LOG_WARNING, LOG_NOTICE, LOG_INFO, and LOG_DEBUG. The default is LOG_INFO. public

Reimplemented from Log.

Definition at line 160 of file daemon.php.

References Log\$_priority, Log\_announce(), Log\_extractMessage(), Log\_isMasked(), _toSyslog(), and open().

{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* If the connection isn't open and can't be opened, return failure. */
if (!$this->_opened && !$this->open()) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
/* Set the facility level. */
$facility_level = intval($this->_name) +
intval($this->_toSyslog($priority));
/* Prepend ident info. */
if (!empty($this->_ident)) {
$message = $this->_ident . ' ' . $message;
}
/* Check for message length. */
if (strlen($message) > $this->_maxsize) {
$message = substr($message, 0, ($this->_maxsize) - 10) . ' [...]';
}
/* Write to socket. */
fwrite($this->_socket, '<' . $facility_level . '>' . $message . "\n");
$this->_announce(array('priority' => $priority, 'message' => $message));
}

+ Here is the call graph for this function:

Log_daemon::Log_daemon (   $name,
  $ident = '',
  $conf = array(),
  $level = PEAR_LOG_DEBUG 
)

Constructs a new syslog object.

Parameters
string$nameThe syslog facility.
string$identThe identity string.
array$confThe configuration array.
int$maxLevelMaximum level at which to log. public

Definition at line 74 of file daemon.php.

References $name, and Log\UPTO().

{
/* Ensure we have a valid integer value for $name. */
if (empty($name) || !is_int($name)) {
$name = LOG_SYSLOG;
}
$this->_id = md5(microtime());
$this->_name = $name;
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
if (isset($conf['ip'])) {
$this->_ip = $conf['ip'];
}
if (isset($conf['proto'])) {
$this->_proto = $conf['proto'];
}
if (isset($conf['port'])) {
$this->_port = $conf['port'];
}
if (isset($conf['maxsize'])) {
$this->_maxsize = $conf['maxsize'];
}
if (isset($conf['timeout'])) {
$this->_timeout = $conf['timeout'];
}
$this->_proto = $this->_proto . '://';
register_shutdown_function(array(&$this, '_Log_daemon'));
}

+ Here is the call graph for this function:

Log_daemon::open ( )

Opens a connection to the system logger, if it has not already been opened.

This is implicitly called by log(), if necessary. public

Reimplemented from Log.

Definition at line 122 of file daemon.php.

References Log\$_opened.

Referenced by log().

{
if (!$this->_opened) {
$this->_opened = (bool)($this->_socket = @fsockopen(
$this->_proto . $this->_ip,
$this->_port,
$errno,
$errstr,
$this->_timeout));
}
}

+ Here is the caller graph for this function:

Field Documentation

Log_daemon::$_ip = '127.0.0.1'

Definition at line 37 of file daemon.php.

Log_daemon::$_maxsize = 4096

Definition at line 56 of file daemon.php.

Log_daemon::$_name = LOG_DAEMON

Definition at line 24 of file daemon.php.

Log_daemon::$_port = 514

Definition at line 50 of file daemon.php.

Log_daemon::$_proto = 'udp'

Definition at line 44 of file daemon.php.

Log_daemon::$_socket

Definition at line 30 of file daemon.php.

Log_daemon::$_timeout = 1

Definition at line 62 of file daemon.php.


The documentation for this class was generated from the following file: