ILIAS  release_4-4 Revision
Log_display Class Reference
+ Inheritance diagram for Log_display:
+ Collaboration diagram for Log_display:

Public Member Functions

 Log_display ($name='', $ident='', $conf=array(), $level=PEAR_LOG_DEBUG)
 Constructs a new Log_display object. More...
 
 open ()
 Opens the display handler. More...
 
 close ()
 Closes the display handler. More...
 
 log ($message, $priority=null)
 Writes $message to the text browser. 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

 $_lineFormat = '<b>%3$s</b>: %4$s'
 
 $_timeFormat = '%b %d %H:%M:%S'
 
- 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 22 of file display.php.

Member Function Documentation

◆ close()

Log_display::close ( )

Closes the display handler.

public

Since
Log 1.9.6

Definition at line 116 of file display.php.

117  {
118  $this->_opened = false;
119  return true;
120  }

◆ log()

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

Writes $message to the text browser.

Also, passes the message along to any Log_observer instances that are observing this Log.

Parameters
mixed$messageString or object containing the message to log.
string$priorityThe 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 on success or false on failure. public

Definition at line 134 of file display.php.

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

135  {
136  /* If a priority hasn't been specified, use the default value. */
137  if ($priority === null) {
138  $priority = $this->_priority;
139  }
140 
141  /* Abort early if the priority is above the maximum logging level. */
142  if (!$this->_isMasked($priority)) {
143  return false;
144  }
145 
146  /* Extract the string representation of the message. */
147  $message = $this->_extractMessage($message);
148 
149  /* Build and output the complete log line. */
150  echo $this->_format($this->_lineFormat,
151  strftime($this->_timeFormat),
152  $priority,
153  nl2br(htmlspecialchars($message)));
154 
155  /* Notify observers about this log message. */
156  $this->_announce(array('priority' => $priority, 'message' => $message));
157 
158  return true;
159  }
_announce($event)
Informs each registered observer instance that a new message has been logged.
Definition: Log.php:811
$_priority
Definition: Log.php:69
_isMasked($priority)
Check if the given priority is included in the current level mask.
Definition: Log.php:726
_extractMessage($message)
Returns the string representation of the message data.
Definition: Log.php:417
_format($format, $timestamp, $priority, $message)
Produces a formatted log line based on a format string and a set of variables representing the curren...
Definition: Log.php:530
+ Here is the call graph for this function:

◆ Log_display()

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

Constructs a new Log_display object.

Parameters
string$nameIgnored.
string$identThe identity string.
array$confThe configuration array.
int$levelLog messages up to and including this level. public

Definition at line 49 of file display.php.

References $_lineFormat, and Log\UPTO().

51  {
52  $this->_id = md5(microtime());
53  $this->_ident = $ident;
54  $this->_mask = Log::UPTO($level);
55 
56  /* Start by configuring the line format. */
57  if (!empty($conf['lineFormat'])) {
58  $this->_lineFormat = str_replace(array_keys($this->_formatMap),
59  array_values($this->_formatMap),
60  $conf['lineFormat']);
61  }
62 
63  /* We may need to prepend a string to our line format. */
64  $prepend = null;
65  if (isset($conf['error_prepend'])) {
66  $prepend = $conf['error_prepend'];
67  } else {
68  $prepend = ini_get('error_prepend_string');
69  }
70  if (!empty($prepend)) {
71  $this->_lineFormat = $prepend . $this->_lineFormat;
72  }
73 
74  /* We may also need to append a string to our line format. */
75  $append = null;
76  if (isset($conf['error_append'])) {
77  $append = $conf['error_append'];
78  } else {
79  $append = ini_get('error_append_string');
80  }
81  if (!empty($append)) {
82  $this->_lineFormat .= $append;
83  }
84 
85  /* Lastly, the line ending sequence is also configurable. */
86  if (isset($conf['linebreak'])) {
87  $this->_lineFormat .= $conf['linebreak'];
88  } else {
89  $this->_lineFormat .= "<br />\n";
90  }
91 
92  /* The user can also change the time format. */
93  if (!empty($conf['timeFormat'])) {
94  $this->_timeFormat = $conf['timeFormat'];
95  }
96  }
UPTO($priority)
Calculate the log mask for all priorities up to the given priority.
Definition: Log.php:642
+ Here is the call graph for this function:

◆ open()

Log_display::open ( )

Opens the display handler.

public

Since
Log 1.9.6

Definition at line 104 of file display.php.

105  {
106  $this->_opened = true;
107  return true;
108  }

Field Documentation

◆ $_lineFormat

Log_display::$_lineFormat = '<b>%3$s</b>: %4$s'

Definition at line 29 of file display.php.

Referenced by Log_display().

◆ $_timeFormat

Log_display::$_timeFormat = '%b %d %H:%M:%S'

Definition at line 38 of file display.php.


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