ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
Log_composite Class Reference
+ Inheritance diagram for Log_composite:
+ Collaboration diagram for Log_composite:

Public Member Functions

 Log_composite ($name, $ident='', $conf=array(), $level=PEAR_LOG_DEBUG)
 Constructs a new composite Log object. More...
 
 open ()
 Opens all of the child instances. More...
 
 close ()
 Closes all of the child instances. More...
 
 flush ()
 Flushes all child instances. More...
 
 log ($message, $priority=null)
 Sends $message and $priority to each child of this composite. More...
 
 isComposite ()
 Returns true if this is a composite. More...
 
 setIdent ($ident)
 Sets this identification string for all of this composite's children. More...
 
 addChild (&$child)
 Adds a Log instance to the list of children. More...
 
 removeChild ($child)
 Removes a Log instance from the list of children. More...
 
- 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. More...
 
factory ($handler, $name='', $ident='', $conf=array(), $level=PEAR_LOG_DEBUG)
 Attempts to return a concrete Log instance of type $handler. More...
 
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. More...
 
 open ()
 Abstract implementation of the open() method. More...
 
 close ()
 Abstract implementation of the close() method. More...
 
 flush ()
 Abstract implementation of the flush() method. More...
 
 log ($message, $priority=null)
 Abstract implementation of the log() method. More...
 
 emerg ($message)
 A convenience function for logging a emergency event. More...
 
 alert ($message)
 A convenience function for logging an alert event. More...
 
 crit ($message)
 A convenience function for logging a critical event. More...
 
 err ($message)
 A convenience function for logging a error event. More...
 
 warning ($message)
 A convenience function for logging a warning event. More...
 
 notice ($message)
 A convenience function for logging a notice event. More...
 
 info ($message)
 A convenience function for logging a information event. More...
 
 debug ($message)
 A convenience function for logging a debug event. More...
 
 _extractMessage ($message)
 Returns the string representation of the message data. More...
 
 _getBacktraceVars ($depth)
 Using debug_backtrace(), returns the file, line, and enclosing function name of the source code context from which log() was invoked. More...
 
 _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. More...
 
 priorityToString ($priority)
 Returns the string representation of a PEAR_LOG_* integer constant. More...
 
 stringToPriority ($name)
 Returns the the PEAR_LOG_* integer constant for the given string representation of a priority name. More...
 
 MASK ($priority)
 Calculate the log mask for the given priority. More...
 
 UPTO ($priority)
 Calculate the log mask for all priorities up to the given priority. More...
 
 MIN ($priority)
 Calculate the log mask for all priorities greater than or equal to the given priority. More...
 
 MAX ($priority)
 Calculate the log mask for all priorities less than or equal to the given priority. More...
 
 setMask ($mask)
 Set and return the level mask for the current Log instance. More...
 
 getMask ()
 Returns the current level mask. More...
 
 _isMasked ($priority)
 Check if the given priority is included in the current level mask. More...
 
 getPriority ()
 Returns the current default priority. More...
 
 setPriority ($priority)
 Sets the default priority to the specified value. More...
 
 attach (&$observer)
 Adds a Log_observer instance to the list of observers that are listening for messages emitted by this Log instance. More...
 
 detach ($observer)
 Removes a Log_observer instance from the list of observers. More...
 
 _announce ($event)
 Informs each registered observer instance that a new message has been logged. More...
 
 isComposite ()
 Indicates whether this is a composite class. More...
 
 setIdent ($ident)
 Sets this Log instance's identification string. More...
 
 getIdent ()
 Returns the current identification string. More...
 

Data Fields

 $_children = array()
 
- 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 23 of file composite.php.

Member Function Documentation

◆ addChild()

Log_composite::addChild ( $child)

Adds a Log instance to the list of children.

Parameters
object$childThe Log instance to add.
Returns
boolean True if the Log instance was successfully added.

public

Definition at line 199 of file composite.php.

200  {
201  /* Make sure this is a Log instance. */
202  if (!is_a($child, 'Log')) {
203  return false;
204  }
205 
206  $this->_children[$child->_id] = &$child;
207 
208  return true;
209  }

◆ close()

Log_composite::close ( )

Closes all of the child instances.

Returns
True if all of the child instances were successfully closed.

public

Definition at line 77 of file composite.php.

78  {
79  /* Attempt to close each of our children. */
80  $closed = true;
81  foreach ($this->_children as $id => $child) {
82  $closed &= $this->_children[$id]->close();
83  }
84 
85  /* Track the _opened state for consistency. */
86  $this->_opened = false;
87 
88  /* If all children were closed, return success. */
89  return $closed;
90  }

◆ flush()

Log_composite::flush ( )

Flushes all child instances.

It is assumed that all of the children have been successfully opened.

Returns
True if all of the child instances were successfully flushed.

public

Since
Log 1.8.2

Definition at line 101 of file composite.php.

102  {
103  /* Attempt to flush each of our children. */
104  $flushed = true;
105  foreach ($this->_children as $id => $child) {
106  $flushed &= $this->_children[$id]->flush();
107  }
108 
109  /* If all children were flushed, return success. */
110  return $flushed;
111  }

◆ isComposite()

Log_composite::isComposite ( )

Returns true if this is a composite.

Returns
boolean True if this is a composite class.

public

Definition at line 166 of file composite.php.

167  {
168  return true;
169  }

◆ log()

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

Sends $message and $priority to each child of this composite.

If the children aren't already open, they will be opened here.

Parameters
mixed$messageString or object containing the message to log.
string$priority(optional) The priority of the message. Valid values are: PEAR_LOG_EMERG, PEAR_LOG_ALERT, PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG.
Returns
boolean True if the entry is successfully logged.

public

Definition at line 130 of file composite.php.

References Log\$_priority, $success, Log\_announce(), and open().

131  {
132  /* If a priority hasn't been specified, use the default value. */
133  if ($priority === null) {
134  $priority = $this->_priority;
135  }
136 
137  /*
138  * If the handlers haven't been opened, attempt to open them now.
139  * However, we don't treat failure to open all of the handlers as a
140  * fatal error. We defer that consideration to the success of calling
141  * each handler's log() method below.
142  */
143  if (!$this->_opened) {
144  $this->open();
145  }
146 
147  /* Attempt to log the event using each of the children. */
148  $success = true;
149  foreach ($this->_children as $id => $child) {
150  $success &= $this->_children[$id]->log($message, $priority);
151  }
152 
153  $this->_announce(array('priority' => $priority, 'message' => $message));
154 
155  /* Return success if all of the children logged the event. */
156  return $success;
157  }
_announce($event)
Informs each registered observer instance that a new message has been logged.
Definition: Log.php:811
open()
Opens all of the child instances.
Definition: composite.php:58
$success
Definition: Utf8Test.php:87
$_priority
Definition: Log.php:69
+ Here is the call graph for this function:

◆ Log_composite()

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

Constructs a new composite Log object.

Parameters
boolean$nameThis parameter is ignored.
boolean$identThis parameter is ignored.
boolean$confThis parameter is ignored.
boolean$levelThis parameter is ignored.

public

Definition at line 45 of file composite.php.

47  {
48  $this->_ident = $ident;
49  }

◆ open()

Log_composite::open ( )

Opens all of the child instances.

Returns
True if all of the child instances were successfully opened.

public

Definition at line 58 of file composite.php.

References Log\$_opened.

Referenced by log().

59  {
60  /* Attempt to open each of our children. */
61  $this->_opened = true;
62  foreach ($this->_children as $id => $child) {
63  $this->_opened &= $this->_children[$id]->open();
64  }
65 
66  /* If all children were opened, return success. */
67  return $this->_opened;
68  }
$_opened
Definition: Log.php:45
+ Here is the caller graph for this function:

◆ removeChild()

Log_composite::removeChild (   $child)

Removes a Log instance from the list of children.

Parameters
object$childThe Log instance to remove.
Returns
boolean True if the Log instance was successfully removed.

public

Definition at line 220 of file composite.php.

221  {
222  if (!is_a($child, 'Log') || !isset($this->_children[$child->_id])) {
223  return false;
224  }
225 
226  unset($this->_children[$child->_id]);
227 
228  return true;
229  }

◆ setIdent()

Log_composite::setIdent (   $ident)

Sets this identification string for all of this composite's children.

Parameters
string$identThe new identification string.

public

Since
Log 1.6.7

Definition at line 179 of file composite.php.

180  {
181  /* Call our base class's setIdent() method. */
182  parent::setIdent($ident);
183 
184  /* ... and then call setIdent() on all of our children. */
185  foreach ($this->_children as $id => $child) {
186  $this->_children[$id]->setIdent($ident);
187  }
188  }

Field Documentation

◆ $_children

Log_composite::$_children = array()

Definition at line 32 of file composite.php.


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