ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
Log_firebug Class Reference
+ Inheritance diagram for Log_firebug:
+ Collaboration diagram for Log_firebug:

Public Member Functions

 Log_firebug ($name='', $ident='PHP', $conf=array(), $level=PEAR_LOG_DEBUG)
 Constructs a new Log_firebug object. More...
 
 open ()
 Opens the firebug handler. More...
 
 _Log_firebug ()
 Destructor. More...
 
 close ()
 Closes the firebug handler. More...
 
 flush ()
 Flushes all pending ("buffered") data. More...
 
 log ($message, $priority=null)
 Writes $message to Firebug console. 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

 $_buffering = false
 
 $_buffer = array()
 
 $_lineFormat = '%2$s [%3$s] %4$s'
 
 $_timeFormat = '%b %d %H:%M:%S'
 
 $_methods
 
- 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 21 of file firebug.php.

Member Function Documentation

◆ _Log_firebug()

Log_firebug::_Log_firebug ( )

Destructor.

Definition at line 120 of file firebug.php.

References close().

121  {
122  $this->close();
123  }
close()
Closes the firebug handler.
Definition: firebug.php:130
+ Here is the call graph for this function:

◆ close()

Log_firebug::close ( )

Closes the firebug handler.

public

Definition at line 130 of file firebug.php.

References flush().

Referenced by _Log_firebug().

131  {
132  $this->flush();
133  $this->_opened = false;
134  return true;
135  }
flush()
Flushes all pending ("buffered") data.
Definition: firebug.php:142
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flush()

Log_firebug::flush ( )

Flushes all pending ("buffered") data.

public

Definition at line 142 of file firebug.php.

Referenced by close().

142  {
143  if (count($this->_buffer)) {
144  print '<script type="text/javascript">';
145  print "\nif (('console' in window) && ('firebug' in console)) {\n";
146  foreach ($this->_buffer as $line) {
147  print " $line\n";
148  }
149  print "}\n";
150  print "</script>\n";
151  };
152  $this->_buffer = array();
153  }
+ Here is the caller graph for this function:

◆ log()

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

Writes $message to Firebug console.

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 167 of file firebug.php.

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

168  {
169  /* If a priority hasn't been specified, use the default value. */
170  if ($priority === null) {
171  $priority = $this->_priority;
172  }
173 
174  /* Abort early if the priority is above the maximum logging level. */
175  if (!$this->_isMasked($priority)) {
176  return false;
177  }
178 
179  /* Extract the string representation of the message. */
180  $message = $this->_extractMessage($message);
181  $method = $this->_methods[$priority];
182 
183  /* normalize line breaks */
184  $message = str_replace("\r\n", "\n", $message);
185 
186  /* escape line breaks */
187  $message = str_replace("\n", "\\n\\\n", $message);
188 
189  /* escape quotes */
190  $message = str_replace('"', '\\"', $message);
191 
192  /* Build the string containing the complete log line. */
193  $line = $this->_format($this->_lineFormat,
194  strftime($this->_timeFormat),
195  $priority,
196  $message);
197 
198  if ($this->_buffering) {
199  $this->_buffer[] = sprintf('console.%s("%s");', $method, $line);
200  } else {
201  print '<script type="text/javascript">';
202  print "\nif (('console' in window) && ('firebug' in console)) {\n";
203  /* Build and output the complete log line. */
204  printf(' console.%s("%s");', $method, $line);
205  print "\n}\n";
206  print "</script>\n";
207  }
208  /* Notify observers about this log message. */
209  $this->_announce(array('priority' => $priority, 'message' => $message));
210 
211  return true;
212  }
_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_firebug()

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

Constructs a new Log_firebug 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 81 of file firebug.php.

References Log\UPTO().

83  {
84  $this->_id = md5(microtime());
85  $this->_ident = $ident;
86  $this->_mask = Log::UPTO($level);
87  if (isset($conf['buffering'])) {
88  $this->_buffering = $conf['buffering'];
89  }
90 
91  if ($this->_buffering) {
92  register_shutdown_function(array(&$this, '_Log_firebug'));
93  }
94 
95  if (!empty($conf['lineFormat'])) {
96  $this->_lineFormat = str_replace(array_keys($this->_formatMap),
97  array_values($this->_formatMap),
98  $conf['lineFormat']);
99  }
100 
101  if (!empty($conf['timeFormat'])) {
102  $this->_timeFormat = $conf['timeFormat'];
103  }
104  }
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_firebug::open ( )

Opens the firebug handler.

public

Definition at line 111 of file firebug.php.

112  {
113  $this->_opened = true;
114  return true;
115  }

Field Documentation

◆ $_buffer

Log_firebug::$_buffer = array()

Definition at line 35 of file firebug.php.

◆ $_buffering

Log_firebug::$_buffering = false

Definition at line 28 of file firebug.php.

◆ $_lineFormat

Log_firebug::$_lineFormat = '%2$s [%3$s] %4$s'

Definition at line 42 of file firebug.php.

◆ $_methods

Log_firebug::$_methods
Initial value:
= array(
PEAR_LOG_EMERG => 'error',
PEAR_LOG_ALERT => 'error',
PEAR_LOG_CRIT => 'error',
PEAR_LOG_ERR => 'error',
PEAR_LOG_WARNING => 'warn',
PEAR_LOG_NOTICE => 'info',
PEAR_LOG_INFO => 'info',
PEAR_LOG_DEBUG => 'debug'
)

Definition at line 61 of file firebug.php.

◆ $_timeFormat

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

Definition at line 54 of file firebug.php.


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