ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
Log_mail Class Reference
+ Inheritance diagram for Log_mail:
+ Collaboration diagram for Log_mail:

Public Member Functions

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

Data Fields

 $_recipients = ''
 $_from = ''
 $_subject = '[Log_mail] Log message'
 $_preamble = ''
 $_lineFormat = '%1$s %2$s [%3$s] %4$s'
 $_timeFormat = '%b %d %H:%M:%S'
 $_message = ''
 $_shouldSend = false
 $_mailBackend = ''
 $_mailParams = 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 28 of file mail.php.

Member Function Documentation

Log_mail::_Log_mail ( )

Destructor.

Calls close().

private

Definition at line 168 of file mail.php.

References close().

{
$this->close();
}

+ Here is the call graph for this function:

Log_mail::close ( )

Closes the message, if it is open, and sends the mail.

This is implicitly called by the destructor, if necessary.

public

Reimplemented from Log.

Definition at line 198 of file mail.php.

References $res, Log\factory(), and PEAR\isError().

Referenced by _Log_mail(), and flush().

{
if ($this->_opened) {
if ($this->_shouldSend && !empty($this->_message)) {
if ($this->_mailBackend === '') { // use mail()
$headers = "From: $this->_from\r\n";
$headers .= 'User-Agent: PEAR Log Package';
if (mail($this->_recipients, $this->_subject,
$this->_message, $headers) == false) {
return false;
}
} else { // use PEAR::Mail
include_once 'Mail.php';
$headers = array('From' => $this->_from,
'To' => $this->_recipients,
'User-Agent' => 'PEAR Log Package',
'Subject' => $this->_subject);
$mailer = &Mail::factory($this->_mailBackend,
$this->_mailParams);
$res = $mailer->send($this->_recipients, $headers,
$this->_message);
return false;
}
}
/* Clear the message string now that the email has been sent. */
$this->_message = '';
$this->_shouldSend = false;
}
$this->_opened = false;
}
return ($this->_opened === false);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Log_mail::flush ( )

Flushes the log output by forcing the email message to be sent now.

Events that are logged after flush() is called will be appended to a new email message.

public

Since
Log 1.8.2

Reimplemented from Log.

Definition at line 242 of file mail.php.

References close().

{
/*
* It's sufficient to simply call close() to flush the output.
* The next call to log() will cause the handler to be reopened.
*/
return $this->close();
}

+ Here is the call graph for this function:

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

Writes $message to the currently open mail message.

Calls open(), if necessary.

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

Reimplemented from Log.

Definition at line 263 of file mail.php.

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

{
/* If a priority hasn't been specified, use the default value. */
if ($priority === null) {
$priority = $this->_priority;
}
/* Abort early if the priority is above the maximum logging level. */
if (!$this->_isMasked($priority)) {
return false;
}
/* If the message isn't open and can't be opened, return failure. */
if (!$this->_opened && !$this->open()) {
return false;
}
/* Extract the string representation of the message. */
$message = $this->_extractMessage($message);
/* Append the string containing the complete log line. */
$this->_message .= $this->_format($this->_lineFormat,
strftime($this->_timeFormat),
$priority, $message) . "\r\n";
$this->_shouldSend = true;
/* Notify observers about this log message. */
$this->_announce(array('priority' => $priority, 'message' => $message));
return true;
}

+ Here is the call graph for this function:

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

Constructs a new Log_mail object.

Here is how you can customize the mail driver with the conf[] hash : $conf['from']: the mail's "From" header line, $conf['subject']: the mail's "Subject" line. $conf['mailBackend']: backend name of PEAR::Mail $conf['mailParams']: parameters for the PEAR::Mail backend

Parameters
string$nameThe message's recipients.
string$identThe identity string.
array$confThe configuration array.
int$levelLog messages up to and including this level. public

Definition at line 119 of file mail.php.

References Log\UPTO().

{
$this->_id = md5(microtime());
$this->_recipients = $name;
$this->_ident = $ident;
$this->_mask = Log::UPTO($level);
if (!empty($conf['from'])) {
$this->_from = $conf['from'];
} else {
$this->_from = ini_get('sendmail_from');
}
if (!empty($conf['subject'])) {
$this->_subject = $conf['subject'];
}
if (!empty($conf['preamble'])) {
$this->_preamble = $conf['preamble'];
}
if (!empty($conf['lineFormat'])) {
$this->_lineFormat = str_replace(array_keys($this->_formatMap),
array_values($this->_formatMap),
$conf['lineFormat']);
}
if (!empty($conf['timeFormat'])) {
$this->_timeFormat = $conf['timeFormat'];
}
if (!empty($conf['mailBackend'])) {
$this->_mailBackend = $conf['mailBackend'];
}
if (!empty($conf['mailParams'])) {
$this->_mailParams = $conf['mailParams'];
}
/* register the destructor */
register_shutdown_function(array(&$this, '_Log_mail'));
}

+ Here is the call graph for this function:

Log_mail::open ( )

Starts a new mail message.

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

public

Reimplemented from Log.

Definition at line 179 of file mail.php.

References Log\$_opened, and $_shouldSend.

Referenced by log().

{
if (!$this->_opened) {
if (!empty($this->_preamble)) {
$this->_message = $this->_preamble . "\r\n\r\n";
}
$this->_opened = true;
$_shouldSend = false;
}
}

+ Here is the caller graph for this function:

Field Documentation

Log_mail::$_from = ''

Definition at line 43 of file mail.php.

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

Definition at line 64 of file mail.php.

Log_mail::$_mailBackend = ''

Definition at line 95 of file mail.php.

Log_mail::$_mailParams = array()

Definition at line 102 of file mail.php.

Log_mail::$_message = ''

Definition at line 80 of file mail.php.

Log_mail::$_preamble = ''

Definition at line 57 of file mail.php.

Log_mail::$_recipients = ''

Definition at line 36 of file mail.php.

Log_mail::$_shouldSend = false

Definition at line 88 of file mail.php.

Referenced by open().

Log_mail::$_subject = '[Log_mail] Log message'

Definition at line 50 of file mail.php.

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

Definition at line 73 of file mail.php.


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