cvs: pear /Log/Log mail.php

From: Date: Sun, 10 Nov 2002 03:47:03 +0000
Subject: cvs: pear /Log/Log mail.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-7341@lists.php.net to get a copy of this message
jon Sat Nov 9 22:47:03 2002 EDT Modified files: /pear/Log/Log mail.php Log: Use PEAR's destructor mechanism to ensure close() gets called (which is responsible for actually sending the email message). Submitted by: Ronnie Garcia <ronnie@mk2.net> Index: pear/Log/Log/mail.php diff -u pear/Log/Log/mail.php:1.3 pear/Log/Log/mail.php:1.4 --- pear/Log/Log/mail.php:1.3 Mon Oct 21 20:13:47 2002 +++ pear/Log/Log/mail.php Sat Nov 9 22:47:03 2002 @@ -1,15 +1,21 @@ <?php -// $Id: mail.php,v 1.3 2002/10/22 00:13:47 jon Exp $ +// $Id: mail.php,v 1.4 2002/11/10 03:47:03 jon Exp $ /** - * The Log_mail class is a concrete implementation of the Log:: - * abstract class which sends log messages to a mailbox. - * The mail is actually sent when you close() the logger. - * If you do not close() it, the pending log messages will be lost. + * The Log_mail class is a concrete implementation of the Log:: abstract class + * which sends log messages to a mailbox. + * The mail is actually sent when you close() the logger, or when the destructor + * is called (when the script is terminated). + * + * PLEASE NOTE that you must create a Log_mail object using =&, like this : + * $logger =& Log::factory("mail", "recipient@example.com", ...) + * + * This is a PEAR requirement for destructors to work properly. + * See http://pear.php.net/manual/en/class.pear.php * * @author Ronnie Garcia <ronnie@mk2.net> * @author Jon Parise <jon@php.net> - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @package Log */ class Log_mail extends Log { @@ -68,11 +74,25 @@ if (!empty($conf['subject'])) { $this->_subject = $conf['subject']; } + + /* register the destructor */ + $this->PEAR(); + } + + /** + * Destructor. Calls close(). + * + * @access private + */ + function _Log_mail() + { + $this->close(); } /** * Starts a new mail message. * This is implicitly called by log(), if necessary. + * * @access public */ function open() @@ -85,6 +105,8 @@ /** * Closes the message, if it is open, and sends the mail. + * This is implicitly called by the destructor, if necessary. + * * @access public */ function close() @@ -107,9 +129,8 @@ } /** - * Writes $message to the currently open mail message. Calls open(), if - * necessary. - * We still need to close() the logger to actually send the mail, thought. + * Writes $message to the currently open mail message. + * Calls open(), if necessary. * * @param string $message The textual message to be logged. * @param string $priority The priority of the message. Valid

« previous php.pear.cvs (#7341) next »