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

Public Member Functions

 Log_mcal ($name, $ident='', $conf=array(), $level=PEAR_LOG_DEBUG)
 Constructs a new Log_mcal object. More...
 
 open ()
 Opens a calendar stream, if it has not already been opened. More...
 
 close ()
 Closes the calendar stream, if it is open. More...
 
 log ($message, $priority=null)
 Logs $message and associated information to the currently open calendar stream. 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

 $_calendar = '{localhost/mstore}'
 
 $_username = ''
 
 $_password = ''
 
 $_options = 0
 
 $_stream = ''
 
 $_name = LOG_SYSLOG
 
- 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 20 of file mcal.php.

Member Function Documentation

◆ close()

Log_mcal::close ( )

Closes the calendar stream, if it is open.

@access public

Reimplemented from Log.

Definition at line 107 of file mcal.php.

108 {
109 if ($this->_opened) {
110 mcal_close($this->_stream);
111 $this->_opened = false;
112 }
113
114 return ($this->_opened === false);
115 }

◆ log()

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

Logs $message and associated information to the currently open calendar stream.

Calls open() if necessary. 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. @access public

Reimplemented from Log.

Definition at line 131 of file mcal.php.

132 {
133 /* If a priority hasn't been specified, use the default value. */
134 if ($priority === null) {
135 $priority = $this->_priority;
136 }
137
138 /* Abort early if the priority is above the maximum logging level. */
139 if (!$this->_isMasked($priority)) {
140 return false;
141 }
142
143 /* If the connection isn't open and can't be opened, return failure. */
144 if (!$this->_opened && !$this->open()) {
145 return false;
146 }
147
148 /* Extract the string representation of the message. */
149 $message = $this->_extractMessage($message);
150
151 $date_str = date('Y:n:j:G:i:s');
152 $dates = explode(':', $date_str);
153
154 mcal_event_init($this->_stream);
155 mcal_event_set_title($this->_stream, $this->_ident);
156 mcal_event_set_category($this->_stream, $this->_name);
157 mcal_event_set_description($this->_stream, $message);
158 mcal_event_add_attribute($this->_stream, 'priority', $priority);
159 mcal_event_set_start($this->_stream, $dates[0], $dates[1], $dates[2],
160 $dates[3], $dates[4], $dates[5]);
161 mcal_event_set_end($this->_stream, $dates[0], $dates[1], $dates[2],
162 $dates[3], $dates[4], $dates[5]);
163 mcal_append_event($this->_stream);
164
165 $this->_announce(array('priority' => $priority, 'message' => $message));
166
167 return true;
168 }
open()
Opens a calendar stream, if it has not already been opened.
Definition: mcal.php:92
$_priority
Definition: Log.php:69
_isMasked($priority)
Check if the given priority is included in the current level mask.
Definition: Log.php:726
_announce($event)
Informs each registered observer instance that a new message has been logged.
Definition: Log.php:811
_extractMessage($message)
Returns the string representation of the message data.
Definition: Log.php:417

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

+ Here is the call graph for this function:

◆ Log_mcal()

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

Constructs a new Log_mcal object.

Parameters
string$nameThe category to use for our events.
string$identThe identity string.
array$confThe configuration array.
int$levelLog messages up to and including this level. @access public

Definition at line 74 of file mcal.php.

76 {
77 $this->_id = md5(microtime());
78 $this->_name = $name;
79 $this->_ident = $ident;
80 $this->_mask = Log::UPTO($level);
81 $this->_calendar = $conf['calendar'];
82 $this->_username = $conf['username'];
83 $this->_password = $conf['password'];
84 $this->_options = $conf['options'];
85 }
UPTO($priority)
Calculate the log mask for all priorities up to the given priority.
Definition: Log.php:642

References Log\UPTO().

+ Here is the call graph for this function:

◆ open()

Log_mcal::open ( )

Opens a calendar stream, if it has not already been opened.

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

Reimplemented from Log.

Definition at line 92 of file mcal.php.

93 {
94 if (!$this->_opened) {
95 $this->_stream = mcal_open($this->_calendar, $this->_username,
96 $this->_password, $this->_options);
97 $this->_opened = true;
98 }
99
100 return $this->_opened;
101 }
$_opened
Definition: Log.php:45

References Log\$_opened.

Referenced by log().

+ Here is the caller graph for this function:

Field Documentation

◆ $_calendar

Log_mcal::$_calendar = '{localhost/mstore}'

Definition at line 27 of file mcal.php.

◆ $_name

Log_mcal::$_name = LOG_SYSLOG

Definition at line 62 of file mcal.php.

◆ $_options

Log_mcal::$_options = 0

Definition at line 48 of file mcal.php.

◆ $_password

Log_mcal::$_password = ''

Definition at line 41 of file mcal.php.

◆ $_stream

Log_mcal::$_stream = ''

Definition at line 55 of file mcal.php.

◆ $_username

Log_mcal::$_username = ''

Definition at line 34 of file mcal.php.


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