cvs: pear /Log/Log composite.php console.php file.php mail.php mcal.php sql.php syslog.php

From: Date: Mon, 02 Dec 2002 05:23:00 +0000
Subject: cvs: pear /Log/Log composite.php console.php file.php mail.php mcal.php sql.php syslog.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-7718@lists.php.net to get a copy of this message
jon Mon Dec 2 00:23:00 2002 EDT Modified files: /pear/Log/Log composite.php console.php file.php mail.php mcal.php sql.php syslog.php Log: - Alter log() to return success or failure. - Document log() as returning a boolean result.

Index: pear/Log/Log/composite.php diff -u pear/Log/Log/composite.php:1.7 pear/Log/Log/composite.php:1.8 --- pear/Log/Log/composite.php:1.7 Mon Oct 21 20:13:47 2002 +++ pear/Log/Log/composite.php Mon Dec 2 00:23:00 2002 @@ -1,5 +1,5 @@ <?php -// $Id: composite.php,v 1.7 2002/10/22 00:13:47 jon Exp $ +// $Id: composite.php,v 1.8 2002/12/02 05:23:00 jon Exp $ // $Horde: horde/lib/Log/composite.php,v 1.2 2000/06/28 21:36:13 jon Exp $ /** @@ -7,7 +7,7 @@ * allows multiple Log implementations to get sent the same events. * * @author Chuck Hagenbuch <chuck@horde.org> - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * @since Horde 1.3 * @package Log */ @@ -75,6 +75,7 @@ * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. * The default is PEAR_LOG_INFO. + * @return boolean True on success or false on failure. */ function log($message, $priority = PEAR_LOG_INFO) { @@ -84,6 +85,8 @@ } $this->notifyAll(array('priority' => $priority, 'message' => $message)); + + return true; } /** Index: pear/Log/Log/console.php diff -u pear/Log/Log/console.php:1.6 pear/Log/Log/console.php:1.7 --- pear/Log/Log/console.php:1.6 Mon Oct 21 20:13:47 2002 +++ pear/Log/Log/console.php Mon Dec 2 00:23:00 2002 @@ -1,12 +1,12 @@ <?php -// $Id: console.php,v 1.6 2002/10/22 00:13:47 jon Exp $ +// $Id: console.php,v 1.7 2002/12/02 05:23:00 jon Exp $ /** * The Log_console class is a concrete implementation of the Log:: * abstract class which writes message to the text console. * * @author Jon Parise <jon@php.net> - * @version $Revision: 1.6 $ + * @version $Revision: 1.7 $ * @package Log */ class Log_console extends Log @@ -37,17 +37,22 @@ * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. * The default is PEAR_LOG_INFO. + * @return boolean True on success or false on failure. * @access public */ function log($message, $priority = PEAR_LOG_INFO) { /* Abort early if the priority is above the maximum logging level. */ - if ($priority > $this->_maxLevel) return; + if ($priority > $this->_maxLevel) { + return false; + } printf("%s %s [%s] %s\n", strftime('%b %d %H:%M:%S'), $this->_ident, Log::priorityToString($priority), $message); $this->notifyAll(array('priority' => $priority, 'message' => $message)); + + return true; } } Index: pear/Log/Log/file.php diff -u pear/Log/Log/file.php:1.13 pear/Log/Log/file.php:1.14 --- pear/Log/Log/file.php:1.13 Thu Nov 28 12:00:08 2002 +++ pear/Log/Log/file.php Mon Dec 2 00:23:00 2002 @@ -33,7 +33,7 @@ // | Jon Parise <jon@php.net> | // +-----------------------------------------------------------------------+ // -// $Id: file.php,v 1.13 2002/11/28 17:00:08 jon Exp $ +// $Id: file.php,v 1.14 2002/12/02 05:23:00 jon Exp $ /** * The Log_file class is a concrete implementation of the Log:: @@ -41,7 +41,7 @@ * on the previous Log_file class by Jon Parise. * * @author Richard Heyes <richard@php.net> -* @version $Revision: 1.13 $ +* @version $Revision: 1.14 $ * @package Log */ class Log_file extends Log @@ -148,6 +148,7 @@ * 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. The default is PEAR_LOG_INFO. + * @return boolean True on success or false on failure. * @access public */ function log($message, $priority = PEAR_LOG_INFO) @@ -162,6 +163,8 @@ // Notify observers $this->notifyAll(array('message' => $message, 'priority' => $priority)); + + return true; } /** Index: pear/Log/Log/mail.php diff -u pear/Log/Log/mail.php:1.4 pear/Log/Log/mail.php:1.5 --- pear/Log/Log/mail.php:1.4 Sat Nov 9 22:47:03 2002 +++ pear/Log/Log/mail.php Mon Dec 2 00:23:00 2002 @@ -1,5 +1,5 @@ <?php -// $Id: mail.php,v 1.4 2002/11/10 03:47:03 jon Exp $ +// $Id: mail.php,v 1.5 2002/12/02 05:23:00 jon Exp $ /** * The Log_mail class is a concrete implementation of the Log:: abstract class @@ -15,7 +15,7 @@ * * @author Ronnie Garcia <ronnie@mk2.net> * @author Jon Parise <jon@php.net> - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ * @package Log */ class Log_mail extends Log { @@ -138,12 +138,15 @@ * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. * The default is PEAR_LOG_INFO. + * @return boolean True on success or false on failure. * @access public */ function log($message, $priority = PEAR_LOG_INFO) { /* Abort early if the priority is above the maximum logging level. */ - if ($priority > $this->_maxLevel) return; + if ($priority > $this->_maxLevel) { + return false; + } if (!$this->_opened) { $this->open(); @@ -155,6 +158,8 @@ $this->_message .= $entry; $this->notifyAll(array('priority' => $priority, 'message' => $message)); + + return true; } } Index: pear/Log/Log/mcal.php diff -u pear/Log/Log/mcal.php:1.7 pear/Log/Log/mcal.php:1.8 --- pear/Log/Log/mcal.php:1.7 Mon Oct 21 20:13:47 2002 +++ pear/Log/Log/mcal.php Mon Dec 2 00:23:00 2002 @@ -1,5 +1,5 @@ <?php -// $Id: mcal.php,v 1.7 2002/10/22 00:13:47 jon Exp $ +// $Id: mcal.php,v 1.8 2002/12/02 05:23:00 jon Exp $ // $Horde: horde/lib/Log/mcal.php,v 1.2 2000/06/28 21:36:13 jon Exp $ /** @@ -8,7 +8,7 @@ * store accessed through MCAL. * * @author Chuck Hagenbuch <chuck@horde.org> - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * @since Horde 1.3 * @package Log */ @@ -110,12 +110,15 @@ * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. * The default is PEAR_LOG_INFO. + * @return boolean True on success or false on failure. * @access public */ function log($message, $priority = PEAR_LOG_INFO) { /* Abort early if the priority is above the maximum logging level. */ - if ($priority > $this->_maxLevel) return; + if ($priority > $this->_maxLevel) { + return false; + } if (!$this->_opened) { $this->open(); @@ -136,6 +139,8 @@ mcal_append_event($this->_stream); $this->notifyAll(array('priority' => $priority, 'message' => $message)); + + return true; } } Index: pear/Log/Log/sql.php diff -u pear/Log/Log/sql.php:1.13 pear/Log/Log/sql.php:1.14 --- pear/Log/Log/sql.php:1.13 Sat Nov 30 16:52:53 2002 +++ pear/Log/Log/sql.php Mon Dec 2 00:23:00 2002 @@ -1,5 +1,5 @@ <?php -// $Id: sql.php,v 1.13 2002/11/30 21:52:53 jon Exp $ +// $Id: sql.php,v 1.14 2002/12/02 05:23:00 jon Exp $ // $Horde: horde/lib/Log/sql.php,v 1.12 2000/08/16 20:27:34 chuck Exp $ require_once 'DB.php'; @@ -20,7 +20,7 @@ * ); * * @author Jon Parise <jon@php.net> - * @version $Revision: 1.13 $ + * @version $Revision: 1.14 $ * @since Horde 1.3 * @package Log */ @@ -126,6 +126,7 @@ * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. * The default is PEAR_LOG_INFO. + * @return boolean True on success or false on failure. * @access public */ function log($message, $priority = PEAR_LOG_INFO) @@ -144,10 +145,12 @@ $result = $this->_db->query($q); if (DB::isError($result)) { - die($result->getMessage()); + return false; } $this->notifyAll(array('priority' => $priority, 'message' => $message)); + + return true; } } Index: pear/Log/Log/syslog.php diff -u pear/Log/Log/syslog.php:1.9 pear/Log/Log/syslog.php:1.10 --- pear/Log/Log/syslog.php:1.9 Fri Oct 25 19:03:13 2002 +++ pear/Log/Log/syslog.php Mon Dec 2 00:23:00 2002 @@ -1,5 +1,5 @@ <?php -// $Id: syslog.php,v 1.9 2002/10/25 23:03:13 jon Exp $ +// $Id: syslog.php,v 1.10 2002/12/02 05:23:00 jon Exp $ // $Horde: horde/lib/Log/syslog.php,v 1.6 2000/06/28 21:36:13 jon Exp $ /** @@ -8,7 +8,7 @@ * (PHP emulates this with the Event Log on Windows machines). * * @author Chuck Hagenbuch <chuck@horde.org> - * @version $Revision: 1.9 $ + * @version $Revision: 1.10 $ * @since Horde 1.3 * @package Log */ @@ -79,19 +79,27 @@ * PEAR_LOG_CRIT, PEAR_LOG_ERR, PEAR_LOG_WARNING, * PEAR_LOG_NOTICE, PEAR_LOG_INFO, and PEAR_LOG_DEBUG. * The default is PEAR_LOG_INFO. + * @return boolean True on success or false on failure. * @access public */ function log($message, $priority = PEAR_LOG_INFO) { /* Abort early if the priority is above the maximum logging level. */ - if ($priority > $this->_maxLevel) return; + if ($priority > $this->_maxLevel) { + return false; + } if (!$this->_opened) { $this->open(); } - syslog($this->_toSyslog($priority), $message); + if (!syslog($this->_toSyslog($priority), $message)) { + return false; + } + $this->notifyAll(array('priority' => $priority, 'message' => $message)); + + return true; } /**
« previous php.pear.cvs (#7718) next »