ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Log Class Reference
+ Inheritance diagram for Log:
+ Collaboration diagram for Log:

Public Member Functions

 _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

 $_opened = false
 
 $_id = 0
 
 $_ident = ''
 
 $_priority = PEAR_LOG_INFO
 
 $_mask = PEAR_LOG_ALL
 
 $_listeners = array()
 
 $_formatMap
 

Detailed Description

Definition at line 37 of file Log.php.

Member Function Documentation

◆ _announce()

Log::_announce (   $event)

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

Parameters
array$eventA hash describing the log event.

@access protected

Definition at line 811 of file Log.php.

812 {
813 foreach ($this->_listeners as $id => $listener) {
814 if ($event['priority'] <= $this->_listeners[$id]->_priority) {
815 $this->_listeners[$id]->notify($event);
816 }
817 }
818 }

Referenced by Log_composite\log(), Log_console\log(), Log_daemon\log(), Log_display\log(), Log_error_log\log(), Log_file\log(), Log_firebug\log(), Log_mail\log(), Log_mcal\log(), Log_mdb2\log(), Log_null\log(), Log_sql\log(), Log_sqlite\log(), Log_syslog\log(), and Log_win\log().

+ Here is the caller graph for this function:

◆ _classExists()

Log::_classExists (   $class)

Utility function which wraps PHP's class_exists() function to ensure consistent behavior between PHP versions 4 and 5.

Autoloading behavior is always disabled.

Parameters
string$classThe name of the class whose existence should be tested.
Returns
bool True if the class exists.

@access private

Since
Log 1.9.13

Definition at line 117 of file Log.php.

118 {
119 if (version_compare(PHP_VERSION, '5.0.0', 'ge')) {
120 return class_exists($class, false);
121 }
122
123 return class_exists($class);
124 }

Referenced by factory().

+ Here is the caller graph for this function:

◆ _extractMessage()

Log::_extractMessage (   $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$messageThe original message data. This may be a string or any object.
Returns
string The string representation of the message.

@access protected

Definition at line 417 of file Log.php.

418 {
419 /*
420 * If we've been given an object, attempt to extract the message using
421 * a known method. If we can't find such a method, default to the
422 * "human-readable" version of the object.
423 *
424 * We also use the human-readable format for arrays.
425 */
426 if (is_object($message)) {
427 if (method_exists($message, 'getmessage')) {
428 $message = $message->getMessage();
429 } else if (method_exists($message, 'tostring')) {
430 $message = $message->toString();
431 } else if (method_exists($message, '__tostring')) {
432 if (version_compare(PHP_VERSION, '5.0.0', 'ge')) {
433 $message = (string)$message;
434 } else {
435 $message = $message->__toString();
436 }
437 } else {
438 $message = var_export($message, true);
439 }
440 } else if (is_array($message)) {
441 if (isset($message['message'])) {
442 if (is_scalar($message['message'])) {
443 $message = $message['message'];
444 } else {
445 $message = var_export($message['message'], true);
446 }
447 } else {
448 $message = var_export($message, true);
449 }
450 } else if (is_bool($message) || $message === NULL) {
451 $message = var_export($message, true);
452 }
453
454 /* Otherwise, we assume the message is a string. */
455 return $message;
456 }

Referenced by Log_console\log(), Log_daemon\log(), Log_display\log(), Log_error_log\log(), Log_file\log(), Log_firebug\log(), Log_mail\log(), Log_mcal\log(), Log_mdb2\log(), Log_sql\log(), Log_sqlite\log(), Log_syslog\log(), and Log_win\log().

+ Here is the caller graph for this function:

◆ _format()

Log::_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.

Returns
string Formatted log string.

@access protected

Since
Log 1.9.4

Definition at line 530 of file Log.php.

531 {
532 /*
533 * If the format string references any of the backtrace-driven
534 * variables (%5 %6,%7,%8), generate the backtrace and fetch them.
535 */
536 if (preg_match('/%[5678]/', $format)) {
537 list($file, $line, $func, $class) = $this->_getBacktraceVars(2);
538 }
539
540 /*
541 * Build the formatted string. We use the sprintf() function's
542 * "argument swapping" capability to dynamically select and position
543 * the variables which will ultimately appear in the log string.
544 */
545 return sprintf($format,
547 $this->_ident,
548 $this->priorityToString($priority),
549 $message,
550 isset($file) ? $file : '',
551 isset($line) ? $line : '',
552 isset($func) ? $func : '',
553 isset($class) ? $class : '');
554 }
print $file
foreach($mandatory_scripts as $file) $timestamp
Definition: buildRTE.php:81
priorityToString($priority)
Returns the string representation of a PEAR_LOG_* integer constant.
Definition: Log.php:566
_getBacktraceVars($depth)
Using debug_backtrace(), returns the file, line, and enclosing function name of the source code conte...
Definition: Log.php:472

References $file, $timestamp, _getBacktraceVars(), and priorityToString().

Referenced by Log_console\log(), Log_display\log(), Log_error_log\log(), Log_file\log(), Log_firebug\log(), and Log_mail\log().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getBacktraceVars()

Log::_getBacktraceVars (   $depth)

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

Parameters
int$depthThe initial number of frames we should step back into the trace.
Returns
array Array containing four strings: the filename, the line, the function name, and the class name from which log() was called.

@access private

Since
Log 1.9.4

Definition at line 472 of file Log.php.

473 {
474 /* Start by generating a backtrace from the current call (here). */
475 $bt = debug_backtrace();
476
477 /*
478 * If we were ultimately invoked by the composite handler, we need to
479 * increase our depth one additional level to compensate.
480 */
481 $class = isset($bt[$depth+1]['class']) ? $bt[$depth+1]['class'] : null;
482 if ($class !== null && strcasecmp($class, 'Log_composite') == 0) {
483 $depth++;
484 $class = isset($bt[$depth + 1]) ? $bt[$depth + 1]['class'] : null;
485 }
486
487 /*
488 * We're interested in the frame which invoked the log() function, so
489 * we need to walk back some number of frames into the backtrace. The
490 * $depth parameter tells us where to start looking. We go one step
491 * further back to find the name of the encapsulating function from
492 * which log() was called.
493 */
494 $file = isset($bt[$depth]) ? $bt[$depth]['file'] : null;
495 $line = isset($bt[$depth]) ? $bt[$depth]['line'] : 0;
496 $func = isset($bt[$depth + 1]) ? $bt[$depth + 1]['function'] : null;
497
498 /*
499 * However, if log() was called from one of our "shortcut" functions,
500 * we're going to need to go back an additional step.
501 */
502 if (in_array($func, array('emerg', 'alert', 'crit', 'err', 'warning',
503 'notice', 'info', 'debug'))) {
504 $file = isset($bt[$depth + 1]) ? $bt[$depth + 1]['file'] : null;
505 $line = isset($bt[$depth + 1]) ? $bt[$depth + 1]['line'] : 0;
506 $func = isset($bt[$depth + 2]) ? $bt[$depth + 2]['function'] : null;
507 }
508
509 /*
510 * If we couldn't extract a function name (perhaps because we were
511 * executed from the "main" context), provide a default value.
512 */
513 if (is_null($func)) {
514 $func = '(none)';
515 }
516
517 /* Return a 4-tuple containing (file, line, function, class). */
518 return array($file, $line, $func, $class);
519 }

References $file.

Referenced by _format().

+ Here is the caller graph for this function:

◆ _isMasked()

Log::_isMasked (   $priority)

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

Parameters
integer$priorityThe priority to check.
Returns
boolean True if the given priority is included in the current log mask.

@access protected

Since
Log 1.7.0

Definition at line 726 of file Log.php.

727 {
728 return (Log::MASK($priority) & $this->_mask);
729 }
MASK($priority)
Calculate the log mask for the given priority.
Definition: Log.php:623

References MASK().

Referenced by Log_console\log(), Log_daemon\log(), Log_display\log(), Log_error_log\log(), Log_file\log(), Log_firebug\log(), Log_mail\log(), Log_mcal\log(), Log_mdb2\log(), Log_null\log(), Log_sql\log(), Log_sqlite\log(), Log_syslog\log(), and Log_win\log().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ alert()

Log::alert (   $message)

A convenience function for logging an alert event.

It will log a message at the PEAR_LOG_ALERT log level.

Parameters
mixed$messageString or object containing the message to log.
Returns
boolean True if the message was successfully logged.

@access public

Since
Log 1.7.0

Definition at line 293 of file Log.php.

294 {
295 return $this->log($message, PEAR_LOG_ALERT);
296 }
const PEAR_LOG_ALERT
Definition: Log.php:11
log($message, $priority=null)
Abstract implementation of the log() method.
Definition: Log.php:259

References log(), and PEAR_LOG_ALERT.

+ Here is the call graph for this function:

◆ attach()

Log::attach ( $observer)

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

Parameters
object$observerThe Log_observer instance to attach as a listener.
booleanTrue if the observer is successfully attached.

@access public

Since
Log 1.0

Definition at line 769 of file Log.php.

770 {
771 if (!is_a($observer, 'Log_observer')) {
772 return false;
773 }
774
775 $this->_listeners[$observer->_id] = &$observer;
776
777 return true;
778 }

◆ close()

Log::close ( )

Abstract implementation of the close() method.

Since
Log 1.0

Reimplemented in Log_composite, Log_console, Log_daemon, Log_display, Log_error_log, Log_file, Log_firebug, Log_mail, Log_mcal, Log_mdb2, Log_null, Log_sql, Log_sqlite, Log_syslog, and Log_win.

Definition at line 241 of file Log.php.

242 {
243 return false;
244 }

◆ crit()

Log::crit (   $message)

A convenience function for logging a critical event.

It will log a message at the PEAR_LOG_CRIT log level.

Parameters
mixed$messageString or object containing the message to log.
Returns
boolean True if the message was successfully logged.

@access public

Since
Log 1.7.0

Definition at line 310 of file Log.php.

311 {
312 return $this->log($message, PEAR_LOG_CRIT);
313 }
const PEAR_LOG_CRIT
Definition: Log.php:12

References log(), and PEAR_LOG_CRIT.

+ Here is the call graph for this function:

◆ debug()

Log::debug (   $message)

A convenience function for logging a debug event.

It will log a message at the PEAR_LOG_DEBUG log level.

Parameters
mixed$messageString or object containing the message to log.
Returns
boolean True if the message was successfully logged.

@access public

Since
Log 1.7.0

Definition at line 395 of file Log.php.

396 {
397 return $this->log($message, PEAR_LOG_DEBUG);
398 }
const PEAR_LOG_DEBUG
Definition: Log.php:17

References log(), and PEAR_LOG_DEBUG.

+ Here is the call graph for this function:

◆ detach()

Log::detach (   $observer)

Removes a Log_observer instance from the list of observers.

Parameters
object$observerThe Log_observer instance to detach from the list of listeners.
booleanTrue if the observer is successfully detached.

@access public

Since
Log 1.0

Definition at line 791 of file Log.php.

792 {
793 if (!is_a($observer, 'Log_observer') ||
794 !isset($this->_listeners[$observer->_id])) {
795 return false;
796 }
797
798 unset($this->_listeners[$observer->_id]);
799
800 return true;
801 }

◆ emerg()

Log::emerg (   $message)

A convenience function for logging a emergency event.

It will log a message at the PEAR_LOG_EMERG log level.

Parameters
mixed$messageString or object containing the message to log.
Returns
boolean True if the message was successfully logged.

@access public

Since
Log 1.7.0

Definition at line 276 of file Log.php.

277 {
278 return $this->log($message, PEAR_LOG_EMERG);
279 }
const PEAR_LOG_EMERG
Definition: Log.php:10

References log(), and PEAR_LOG_EMERG.

+ Here is the call graph for this function:

◆ err()

Log::err (   $message)

A convenience function for logging a error event.

It will log a message at the PEAR_LOG_ERR log level.

Parameters
mixed$messageString or object containing the message to log.
Returns
boolean True if the message was successfully logged.

@access public

Since
Log 1.7.0

Definition at line 327 of file Log.php.

328 {
329 return $this->log($message, PEAR_LOG_ERR);
330 }
const PEAR_LOG_ERR
Definition: Log.php:13

References log(), and PEAR_LOG_ERR.

+ Here is the call graph for this function:

◆ factory()

& Log::factory (   $handler,
  $name = '',
  $ident = '',
  $conf = array(),
  $level = PEAR_LOG_DEBUG 
)

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

Parameters
string$handlerThe 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$nameThe 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$identThe identity reported to the log system.
array$confA hash containing any additional configuration information that a subclass might need.
int$levelLog messages up to and including this level.
Returns
object Log The newly created concrete Log instance, or null on an error. @access public
Since
Log 1.0

Definition at line 151 of file Log.php.

153 {
154 $handler = strtolower($handler);
155 $class = 'Log_' . $handler;
156 $classfile = 'Log/' . $handler . '.php';
157
158 /*
159 * Attempt to include our version of the named class, but don't treat
160 * a failure as fatal. The caller may have already included their own
161 * version of the named class.
162 */
163 if (!Log::_classExists($class)) {
164 include_once $classfile;
165 }
166
167 /* If the class exists, return a new instance of it. */
168 if (Log::_classExists($class)) {
169 $obj = new $class($name, $ident, $conf, $level);
170 return $obj;
171 }
172
173 $null = null;
174 return $null;
175 }
_classExists($class)
Utility function which wraps PHP's class_exists() function to ensure consistent behavior between PHP ...
Definition: Log.php:117

References _classExists().

Referenced by singleton().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ flush()

Log::flush ( )

Abstract implementation of the flush() method.

Since
Log 1.8.2

Reimplemented in Log_composite, Log_console, Log_file, Log_firebug, and Log_mail.

Definition at line 250 of file Log.php.

251 {
252 return false;
253 }

◆ getIdent()

Log::getIdent ( )

Returns the current identification string.

Returns
string The current Log instance's identification string.

@access public

Since
Log 1.6.3

Definition at line 854 of file Log.php.

855 {
856 return $this->_ident;
857 }
$_ident
Definition: Log.php:61

References $_ident.

◆ getMask()

Log::getMask ( )

Returns the current level mask.

Returns
interger The current level mask.

@access public

Since
Log 1.7.0

Definition at line 710 of file Log.php.

711 {
712 return $this->_mask;
713 }
$_mask
Definition: Log.php:77

References $_mask.

◆ getPriority()

Log::getPriority ( )

Returns the current default priority.

Returns
integer The current default priority.

@access public

Since
Log 1.8.4

Definition at line 739 of file Log.php.

740 {
741 return $this->_priority;
742 }
$_priority
Definition: Log.php:69

References $_priority.

◆ info()

Log::info (   $message)

A convenience function for logging a information event.

It will log a message at the PEAR_LOG_INFO log level.

Parameters
mixed$messageString or object containing the message to log.
Returns
boolean True if the message was successfully logged.

@access public

Since
Log 1.7.0

Definition at line 378 of file Log.php.

379 {
380 return $this->log($message, PEAR_LOG_INFO);
381 }
const PEAR_LOG_INFO
Definition: Log.php:16

References log(), and PEAR_LOG_INFO.

+ Here is the call graph for this function:

◆ isComposite()

Log::isComposite ( )

Indicates whether this is a composite class.

Returns
boolean True if this is a composite class.

@access public

Since
Log 1.0

Reimplemented in Log_composite.

Definition at line 828 of file Log.php.

829 {
830 return false;
831 }

◆ log()

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

Abstract implementation of the log() method.

Since
Log 1.0

Reimplemented in Log_composite, Log_console, Log_daemon, Log_display, Log_error_log, Log_file, Log_firebug, Log_mail, Log_mcal, Log_mdb2, Log_null, Log_sql, Log_sqlite, Log_syslog, and Log_win.

Definition at line 259 of file Log.php.

260 {
261 return false;
262 }

Referenced by alert(), crit(), debug(), emerg(), err(), info(), notice(), and warning().

+ Here is the caller graph for this function:

◆ MASK()

Log::MASK (   $priority)

Calculate the log mask for the given priority.

This method may be called statically.

Parameters
integer$priorityThe priority whose mask will be calculated.
Returns
integer The calculated log mask.

@access public

Since
Log 1.7.0

Definition at line 623 of file Log.php.

624 {
625 return (1 << $priority);
626 }

Referenced by _isMasked().

+ Here is the caller graph for this function:

◆ MAX()

Log::MAX (   $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$priorityThe maximum priority covered by this mask.
Returns
integer The resulting log mask.

@access public

Since
Log 1.9.4

Definition at line 680 of file Log.php.

681 {
682 return ((1 << ($priority + 1)) - 1);
683 }

Referenced by UPTO().

+ Here is the caller graph for this function:

◆ MIN()

Log::MIN (   $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$priorityThe minimum priority covered by this mask.
Returns
integer The resulting log mask.

@access public

Since
Log 1.9.4

Definition at line 661 of file Log.php.

662 {
663 return PEAR_LOG_ALL ^ ((1 << $priority) - 1);
664 }
const PEAR_LOG_ALL
Definition: Log.php:19

References PEAR_LOG_ALL.

◆ notice()

Log::notice (   $message)

A convenience function for logging a notice event.

It will log a message at the PEAR_LOG_NOTICE log level.

Parameters
mixed$messageString or object containing the message to log.
Returns
boolean True if the message was successfully logged.

@access public

Since
Log 1.7.0

Definition at line 361 of file Log.php.

362 {
363 return $this->log($message, PEAR_LOG_NOTICE);
364 }
const PEAR_LOG_NOTICE
Definition: Log.php:15

References log(), and PEAR_LOG_NOTICE.

+ Here is the call graph for this function:

◆ open()

Log::open ( )

Abstract implementation of the open() method.

Since
Log 1.0

Reimplemented in Log_composite, Log_console, Log_daemon, Log_display, Log_error_log, Log_file, Log_firebug, Log_mail, Log_mcal, Log_mdb2, Log_null, Log_sql, Log_sqlite, Log_syslog, and Log_win.

Definition at line 232 of file Log.php.

233 {
234 return false;
235 }

◆ priorityToString()

Log::priorityToString (   $priority)

Returns the string representation of a PEAR_LOG_* integer constant.

Parameters
int$priorityA PEAR_LOG_* integer constant.
Returns
string The string representation of $level.

@access public

Since
Log 1.0

Definition at line 566 of file Log.php.

567 {
568 $levels = array(
569 PEAR_LOG_EMERG => 'emergency',
570 PEAR_LOG_ALERT => 'alert',
571 PEAR_LOG_CRIT => 'critical',
572 PEAR_LOG_ERR => 'error',
573 PEAR_LOG_WARNING => 'warning',
574 PEAR_LOG_NOTICE => 'notice',
575 PEAR_LOG_INFO => 'info',
576 PEAR_LOG_DEBUG => 'debug'
577 );
578
579 return $levels[$priority];
580 }
const PEAR_LOG_WARNING
Definition: Log.php:14

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 _format(), and Log_win\log().

+ Here is the caller graph for this function:

◆ setIdent()

Log::setIdent (   $ident)

Sets this Log instance's identification string.

Parameters
string$identThe new identification string.

@access public

Since
Log 1.6.3

Reimplemented in Log_composite, Log_mdb2, and Log_sql.

Definition at line 841 of file Log.php.

842 {
843 $this->_ident = $ident;
844 }

◆ setMask()

Log::setMask (   $mask)

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

Parameters
integer$maskA bitwise mask of log levels.
Returns
integer The current level mask.

@access public

Since
Log 1.7.0

Definition at line 695 of file Log.php.

696 {
697 $this->_mask = $mask;
698
699 return $this->_mask;
700 }
$mask
Definition: example_042.php:90

References $_mask, and $mask.

◆ setPriority()

Log::setPriority (   $priority)

Sets the default priority to the specified value.

Parameters
integer$priorityThe new default priority.

@access public

Since
Log 1.8.4

Definition at line 752 of file Log.php.

753 {
754 $this->_priority = $priority;
755 }

◆ singleton()

& Log::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.

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$handlerThe 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$nameThe 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$identThe identity reported to the log system.
array$confA hash containing any additional configuration information that a subclass might need.
int$levelLog messages up to and including this level.
Returns
object Log The newly created concrete Log instance, or null on an error. @access public
Since
Log 1.0

Definition at line 213 of file Log.php.

215 {
216 static $instances;
217 if (!isset($instances)) $instances = array();
218
219 $signature = serialize(array($handler, $name, $ident, $conf, $level));
220 if (!isset($instances[$signature])) {
221 $instances[$signature] = &Log::factory($handler, $name, $ident,
222 $conf, $level);
223 }
224
225 return $instances[$signature];
226 }
& factory($handler, $name='', $ident='', $conf=array(), $level=PEAR_LOG_DEBUG)
Attempts to return a concrete Log instance of type $handler.
Definition: Log.php:151

References factory().

Referenced by Auth\_loadLogger().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stringToPriority()

Log::stringToPriority (   $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$nameString containing a priority name.
Returns
string The PEAR_LOG_* integer contstant corresponding the the specified priority name.

@access public

Since
Log 1.9.0

Definition at line 595 of file Log.php.

596 {
597 $levels = array(
598 'emergency' => PEAR_LOG_EMERG,
599 'alert' => PEAR_LOG_ALERT,
600 'critical' => PEAR_LOG_CRIT,
601 'error' => PEAR_LOG_ERR,
602 'warning' => PEAR_LOG_WARNING,
603 'notice' => PEAR_LOG_NOTICE,
604 'info' => PEAR_LOG_INFO,
605 'debug' => PEAR_LOG_DEBUG
606 );
607
608 return $levels[strtolower($name)];
609 }

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.

◆ UPTO()

Log::UPTO (   $priority)

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

This method may be called statically.

Parameters
integer$priorityThe maximum priority covered by this mask.
Returns
integer The resulting log mask.

@access public

Since
Log 1.7.0
Deprecated:
deprecated since Log 1.9.4; use Log::MAX() instead

Definition at line 642 of file Log.php.

643 {
644 return Log::MAX($priority);
645 }
MAX($priority)
Calculate the log mask for all priorities less than or equal to the given priority.
Definition: Log.php:680

References MAX().

Referenced by Log_console\Log_console(), Log_daemon\Log_daemon(), Log_display\Log_display(), Log_error_log\Log_error_log(), Log_file\Log_file(), Log_firebug\Log_firebug(), Log_mail\Log_mail(), Log_mcal\Log_mcal(), Log_mdb2\Log_mdb2(), Log_null\Log_null(), Log_sql\Log_sql(), Log_sqlite\Log_sqlite(), Log_syslog\Log_syslog(), and Log_win\Log_win().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ warning()

Log::warning (   $message)

A convenience function for logging a warning event.

It will log a message at the PEAR_LOG_WARNING log level.

Parameters
mixed$messageString or object containing the message to log.
Returns
boolean True if the message was successfully logged.

@access public

Since
Log 1.7.0

Definition at line 344 of file Log.php.

345 {
346 return $this->log($message, PEAR_LOG_WARNING);
347 }

References log(), and PEAR_LOG_WARNING.

+ Here is the call graph for this function:

Field Documentation

◆ $_formatMap

Log::$_formatMap
Initial value:
= array('%{timestamp}' => '%1$s',
'%{ident}' => '%2$s',
'%{priority}' => '%3$s',
'%{message}' => '%4$s',
'%{file}' => '%5$s',
'%{line}' => '%6$s',
'%{function}' => '%7$s',
'%{class}' => '%8$s',
'%\{' => '%%{')

Definition at line 94 of file Log.php.

◆ $_id

Log::$_id = 0

Definition at line 53 of file Log.php.

◆ $_ident

Log::$_ident = ''

Definition at line 61 of file Log.php.

Referenced by getIdent().

◆ $_listeners

Log::$_listeners = array()

Definition at line 85 of file Log.php.

◆ $_mask

Log::$_mask = PEAR_LOG_ALL

Definition at line 77 of file Log.php.

Referenced by getMask(), and setMask().

◆ $_opened

◆ $_priority


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