cvs: pear /Log Log.php /Log/Log composite.php console.php file.php mcal.php sql.php syslog.php
| From: | Jon Parise | Date: | Mon, 29 Apr 2002 05:18:46 +0000 |
| Subject: | cvs: pear /Log Log.php /Log/Log composite.php console.php file.php mcal.php sql.php syslog.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-3614@lists.php.net to get a copy of this message | ||
jon Mon Apr 29 01:18:46 2002 EDT
Modified files:
/pear/Log Log.php
/pear/Log/Log composite.php console.php file.php mcal.php sql.php
syslog.php
Log:
Implement a maximum logging level setting. Messages whose priorities are
above the maximum log level will not be logged.
The default maximum log level is LOG_DEBUG (the highest priority), so all
messages will be logged. Therefore, existing behavior remains unchanged.
Requested by: "robert janeczek" <rashid@ds.pg.gda.pl>
Index: pear/Log/Log.php diff -u pear/Log/Log.php:1.7 pear/Log/Log.php:1.8 --- pear/Log/Log.php:1.7 Mon Apr 29 00:52:21 2002 +++ pear/Log/Log.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: Log.php,v 1.7 2002/04/29 04:52:21 jon Exp $ +// $Id: Log.php,v 1.8 2002/04/29 05:18:45 jon Exp $ // $Horde: horde/lib/Log.php,v 1.15 2000/06/29 23:39:45 jon Exp $ /** @@ -8,7 +8,7 @@ * * @author Chuck Hagenbuch <chuck@horde.org> * @author Jon Parise <jon@horde.org> - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * @since Horde 1.3 * @package Log */ @@ -31,6 +31,14 @@ var $_ident = ''; /** + * The maximum priority level at which to log a message. + * + * @var int + * @access private + */ + var $_maxLevel = LOG_DEBUG; + + /** * Holds all Log_observer objects that wish to be notified of new messages. * * @var array @@ -56,18 +64,21 @@ * * @param array $conf A hash containing any additional configuration * information that a subclass might need. + * + * @param int $maxLevel Maximum priority level at which to log. * * @return object Log The newly created concrete Log instance, or an * false on an error. * @access public */ - function factory($type, $name = '', $ident = '', $conf = array()) + function factory($type, $name = '', $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { $type = strtolower($type); $classfile = 'Log/' . $type . '.php'; if (@include_once $classfile) { $class = 'Log_' . $type; - return new $class($name, $ident, $conf); + return new $class($name, $ident, $conf, $maxLevel); } else { return false; } @@ -102,18 +113,22 @@ * @param array $conf A hash containing any additional configuration * information that a subclass might need. * + * @param int $maxLevel Minimum priority level at which to log. + * * @return object Log The newly created concrete Log instance, or an * false on an error. * @access public */ - function &singleton($type, $name = '', $ident = '', $conf = array()) + function &singleton($type, $name = '', $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { static $instances; if (!isset($instances)) $instances = array(); - $signature = md5($type . '][' . $name . '][' . $ident . '][' . implode('][', $conf)); + $signature = md5($type . '][' . $name . '][' . $ident . '][' . implode('][', $conf) . '][' . $maxLevel); if (!isset($instances[$signature])) { - $instances[$signature] = Log::factory($type, $name, $ident, $conf); + $instances[$signature] = Log::factory($type, $name, $ident, $conf, + $maxLevel); } return $instances[$signature]; Index: pear/Log/Log/composite.php diff -u pear/Log/Log/composite.php:1.3 pear/Log/Log/composite.php:1.4 --- pear/Log/Log/composite.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/composite.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: composite.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: composite.php,v 1.4 2002/04/29 05:18:45 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.3 $ + * @version $Revision: 1.4 $ * @since Horde 1.3 * @package Log */ @@ -28,9 +28,11 @@ * @param boolean $name This is ignored. * @param boolean $ident This is ignored. * @param boolean $conf This is ignored. + * @param boolean $maxLevel This is ignored. * @access public */ - function Log_composite($name = false, $ident = false, $conf = false) + function Log_composite($name = false, $ident = false, $conf = false, + $maxLevel = LOG_DEBUG) { } Index: pear/Log/Log/console.php diff -u pear/Log/Log/console.php:1.3 pear/Log/Log/console.php:1.4 --- pear/Log/Log/console.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/console.php Mon Apr 29 01:18:45 2002 @@ -1,12 +1,12 @@ <?php -// $Id: console.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: console.php,v 1.4 2002/04/29 05:18:45 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.3 $ + * @version $Revision: 1.4 $ * @package Log */ class Log_console extends Log @@ -17,11 +17,14 @@ * @param string $name Ignored. * @param string $ident The identity string. * @param array $conf The configuration array. + * @param array $maxLevel Maximum priority level at which to log. * @access public */ - function Log_console($name, $ident = '', $conf = array()) + function Log_console($name, $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { $this->_ident = $ident; + $this->_maxLevel = $maxLevel; } /** @@ -37,6 +40,9 @@ */ function log($message, $priority = LOG_INFO) { + /* Abort early if the priority is above the maximum logging level. */ + if ($priority > $this->_maxLevel) return; + printf("%s %s [%s] %s\n", strftime('%b %d %T'), $this->_ident, Log::priorityToString($priority), $message); Index: pear/Log/Log/file.php diff -u pear/Log/Log/file.php:1.3 pear/Log/Log/file.php:1.4 --- pear/Log/Log/file.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/file.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: file.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: file.php,v 1.4 2002/04/29 05:18:45 jon Exp $ // $Horde: horde/lib/Log/file.php,v 1.4 2000/06/28 21:36:13 jon Exp $ /** @@ -7,7 +7,7 @@ * abstract class which writes message to a text file. * * @author Jon Parise <jon@horde.org> - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @since Horde 1.3 * @package Log */ @@ -32,9 +32,11 @@ * @param string $name The filename of the logfile. * @param string $ident The identity string. * @param array $conf The configuration array. + * @param int $maxLevel Maximum level at which to log. * @access public */ - function Log_file($name, $ident = '', $conf = array()) + function Log_file($name, $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { // bc compatibilty if( 0 == count( $conf )) { @@ -42,6 +44,7 @@ } $this->filename = $name; $this->_ident = $ident; + $this->_maxLevel = $maxLevel; } /** @@ -84,6 +87,9 @@ */ function log($message, $priority = LOG_INFO) { + /* Abort early if the priority is above the maximum logging level. */ + if ($priority > $this->_maxLevel) return; + if (!$this->_opened) { $this->open(); } Index: pear/Log/Log/mcal.php diff -u pear/Log/Log/mcal.php:1.3 pear/Log/Log/mcal.php:1.4 --- pear/Log/Log/mcal.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/mcal.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: mcal.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: mcal.php,v 1.4 2002/04/29 05:18:45 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.3 $ + * @version $Revision: 1.4 $ * @since Horde 1.3 * @package Log */ @@ -57,9 +57,11 @@ * @param string $name The category to use for our events. * @param string $ident The identity string. * @param array $conf The configuration array. + * @param int $maxLevel Maximum level at which to log. * @access public */ - function Log_mcal($name, $ident = '', $conf = array()) + function Log_mcal($name, $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { // bc compatibilty if( 0 == count( $conf )) { @@ -67,6 +69,7 @@ } $this->name = $name; $this->_ident = $ident; + $this->_maxLevel = $maxLevel; $this->calendar = $conf['calendar']; $this->username = $conf['username']; $this->password = $conf['password']; @@ -113,6 +116,9 @@ */ function log($message, $priority = LOG_INFO) { + /* Abort early if the priority is above the maximum logging level. */ + if ($priority > $this->_maxLevel) return; + if (!$this->_opened) { $this->open(); } Index: pear/Log/Log/sql.php diff -u pear/Log/Log/sql.php:1.3 pear/Log/Log/sql.php:1.4 --- pear/Log/Log/sql.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/sql.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: sql.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: sql.php,v 1.4 2002/04/29 05:18:45 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@horde.org> - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @since Horde 1.3 * @package Log */ @@ -51,12 +51,14 @@ * @param string $name The target SQL table. * @param string $ident The identification field. * @param array $conf The connection configuration array. + * @param int $maxLevel Maximum level at which to log. * @access public */ - function Log_sql($name, $ident = '', $conf) + function Log_sql($name, $ident = '', $conf = array(), $maxLevel = LOG_DEBUG) { $this->table = $name; $this->_ident = $ident; + $this->_maxLevel = $maxLevel; $this->dsn = $conf['dsn']; } @@ -110,6 +112,9 @@ */ function log($message, $priority = LOG_INFO) { + /* Abort early if the priority is above the maximum logging level. */ + if ($priority > $this->_maxLevel) return; + if (!$this->_opened) { $this->open(); } Index: pear/Log/Log/syslog.php diff -u pear/Log/Log/syslog.php:1.3 pear/Log/Log/syslog.php:1.4 --- pear/Log/Log/syslog.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/syslog.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: syslog.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: syslog.php,v 1.4 2002/04/29 05:18:45 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.3 $ + * @version $Revision: 1.4 $ * @since Horde 1.3 * @package Log */ @@ -27,9 +27,11 @@ * @param string $name The syslog facility. * @param string $ident The identity string. * @param array $conf The configuration array. + * @param int $maxLevel Maximum level at which to log. * @access public */ - function Log_syslog($name, $ident = '', $conf = array()) + function Log_syslog($name, $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { // bc compatibilty if( 0 == count( $conf )) { @@ -37,6 +39,7 @@ } $this->name = $name; $this->_ident = $ident; + $this->_maxLevel = $maxLevel; } /** @@ -78,6 +81,9 @@ */ function log($message, $priority = LOG_INFO) { + /* Abort early if the priority is above the maximum logging level. */ + if ($priority > $this->_maxLevel) return; + if (!$this->_opened) { $this->open(); }
Index: pear/Log/Log.php diff -u pear/Log/Log.php:1.7 pear/Log/Log.php:1.8 --- pear/Log/Log.php:1.7 Mon Apr 29 00:52:21 2002 +++ pear/Log/Log.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: Log.php,v 1.7 2002/04/29 04:52:21 jon Exp $ +// $Id: Log.php,v 1.8 2002/04/29 05:18:45 jon Exp $ // $Horde: horde/lib/Log.php,v 1.15 2000/06/29 23:39:45 jon Exp $ /** @@ -8,7 +8,7 @@ * * @author Chuck Hagenbuch <chuck@horde.org> * @author Jon Parise <jon@horde.org> - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ * @since Horde 1.3 * @package Log */ @@ -31,6 +31,14 @@ var $_ident = ''; /** + * The maximum priority level at which to log a message. + * + * @var int + * @access private + */ + var $_maxLevel = LOG_DEBUG; + + /** * Holds all Log_observer objects that wish to be notified of new messages. * * @var array @@ -56,18 +64,21 @@ * * @param array $conf A hash containing any additional configuration * information that a subclass might need. + * + * @param int $maxLevel Maximum priority level at which to log. * * @return object Log The newly created concrete Log instance, or an * false on an error. * @access public */ - function factory($type, $name = '', $ident = '', $conf = array()) + function factory($type, $name = '', $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { $type = strtolower($type); $classfile = 'Log/' . $type . '.php'; if (@include_once $classfile) { $class = 'Log_' . $type; - return new $class($name, $ident, $conf); + return new $class($name, $ident, $conf, $maxLevel); } else { return false; } @@ -102,18 +113,22 @@ * @param array $conf A hash containing any additional configuration * information that a subclass might need. * + * @param int $maxLevel Minimum priority level at which to log. + * * @return object Log The newly created concrete Log instance, or an * false on an error. * @access public */ - function &singleton($type, $name = '', $ident = '', $conf = array()) + function &singleton($type, $name = '', $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { static $instances; if (!isset($instances)) $instances = array(); - $signature = md5($type . '][' . $name . '][' . $ident . '][' . implode('][', $conf)); + $signature = md5($type . '][' . $name . '][' . $ident . '][' . implode('][', $conf) . '][' . $maxLevel); if (!isset($instances[$signature])) { - $instances[$signature] = Log::factory($type, $name, $ident, $conf); + $instances[$signature] = Log::factory($type, $name, $ident, $conf, + $maxLevel); } return $instances[$signature]; Index: pear/Log/Log/composite.php diff -u pear/Log/Log/composite.php:1.3 pear/Log/Log/composite.php:1.4 --- pear/Log/Log/composite.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/composite.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: composite.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: composite.php,v 1.4 2002/04/29 05:18:45 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.3 $ + * @version $Revision: 1.4 $ * @since Horde 1.3 * @package Log */ @@ -28,9 +28,11 @@ * @param boolean $name This is ignored. * @param boolean $ident This is ignored. * @param boolean $conf This is ignored. + * @param boolean $maxLevel This is ignored. * @access public */ - function Log_composite($name = false, $ident = false, $conf = false) + function Log_composite($name = false, $ident = false, $conf = false, + $maxLevel = LOG_DEBUG) { } Index: pear/Log/Log/console.php diff -u pear/Log/Log/console.php:1.3 pear/Log/Log/console.php:1.4 --- pear/Log/Log/console.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/console.php Mon Apr 29 01:18:45 2002 @@ -1,12 +1,12 @@ <?php -// $Id: console.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: console.php,v 1.4 2002/04/29 05:18:45 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.3 $ + * @version $Revision: 1.4 $ * @package Log */ class Log_console extends Log @@ -17,11 +17,14 @@ * @param string $name Ignored. * @param string $ident The identity string. * @param array $conf The configuration array. + * @param array $maxLevel Maximum priority level at which to log. * @access public */ - function Log_console($name, $ident = '', $conf = array()) + function Log_console($name, $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { $this->_ident = $ident; + $this->_maxLevel = $maxLevel; } /** @@ -37,6 +40,9 @@ */ function log($message, $priority = LOG_INFO) { + /* Abort early if the priority is above the maximum logging level. */ + if ($priority > $this->_maxLevel) return; + printf("%s %s [%s] %s\n", strftime('%b %d %T'), $this->_ident, Log::priorityToString($priority), $message); Index: pear/Log/Log/file.php diff -u pear/Log/Log/file.php:1.3 pear/Log/Log/file.php:1.4 --- pear/Log/Log/file.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/file.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: file.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: file.php,v 1.4 2002/04/29 05:18:45 jon Exp $ // $Horde: horde/lib/Log/file.php,v 1.4 2000/06/28 21:36:13 jon Exp $ /** @@ -7,7 +7,7 @@ * abstract class which writes message to a text file. * * @author Jon Parise <jon@horde.org> - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @since Horde 1.3 * @package Log */ @@ -32,9 +32,11 @@ * @param string $name The filename of the logfile. * @param string $ident The identity string. * @param array $conf The configuration array. + * @param int $maxLevel Maximum level at which to log. * @access public */ - function Log_file($name, $ident = '', $conf = array()) + function Log_file($name, $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { // bc compatibilty if( 0 == count( $conf )) { @@ -42,6 +44,7 @@ } $this->filename = $name; $this->_ident = $ident; + $this->_maxLevel = $maxLevel; } /** @@ -84,6 +87,9 @@ */ function log($message, $priority = LOG_INFO) { + /* Abort early if the priority is above the maximum logging level. */ + if ($priority > $this->_maxLevel) return; + if (!$this->_opened) { $this->open(); } Index: pear/Log/Log/mcal.php diff -u pear/Log/Log/mcal.php:1.3 pear/Log/Log/mcal.php:1.4 --- pear/Log/Log/mcal.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/mcal.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: mcal.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: mcal.php,v 1.4 2002/04/29 05:18:45 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.3 $ + * @version $Revision: 1.4 $ * @since Horde 1.3 * @package Log */ @@ -57,9 +57,11 @@ * @param string $name The category to use for our events. * @param string $ident The identity string. * @param array $conf The configuration array. + * @param int $maxLevel Maximum level at which to log. * @access public */ - function Log_mcal($name, $ident = '', $conf = array()) + function Log_mcal($name, $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { // bc compatibilty if( 0 == count( $conf )) { @@ -67,6 +69,7 @@ } $this->name = $name; $this->_ident = $ident; + $this->_maxLevel = $maxLevel; $this->calendar = $conf['calendar']; $this->username = $conf['username']; $this->password = $conf['password']; @@ -113,6 +116,9 @@ */ function log($message, $priority = LOG_INFO) { + /* Abort early if the priority is above the maximum logging level. */ + if ($priority > $this->_maxLevel) return; + if (!$this->_opened) { $this->open(); } Index: pear/Log/Log/sql.php diff -u pear/Log/Log/sql.php:1.3 pear/Log/Log/sql.php:1.4 --- pear/Log/Log/sql.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/sql.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: sql.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: sql.php,v 1.4 2002/04/29 05:18:45 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@horde.org> - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @since Horde 1.3 * @package Log */ @@ -51,12 +51,14 @@ * @param string $name The target SQL table. * @param string $ident The identification field. * @param array $conf The connection configuration array. + * @param int $maxLevel Maximum level at which to log. * @access public */ - function Log_sql($name, $ident = '', $conf) + function Log_sql($name, $ident = '', $conf = array(), $maxLevel = LOG_DEBUG) { $this->table = $name; $this->_ident = $ident; + $this->_maxLevel = $maxLevel; $this->dsn = $conf['dsn']; } @@ -110,6 +112,9 @@ */ function log($message, $priority = LOG_INFO) { + /* Abort early if the priority is above the maximum logging level. */ + if ($priority > $this->_maxLevel) return; + if (!$this->_opened) { $this->open(); } Index: pear/Log/Log/syslog.php diff -u pear/Log/Log/syslog.php:1.3 pear/Log/Log/syslog.php:1.4 --- pear/Log/Log/syslog.php:1.3 Mon Apr 29 00:52:22 2002 +++ pear/Log/Log/syslog.php Mon Apr 29 01:18:45 2002 @@ -1,5 +1,5 @@ <?php -// $Id: syslog.php,v 1.3 2002/04/29 04:52:22 jon Exp $ +// $Id: syslog.php,v 1.4 2002/04/29 05:18:45 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.3 $ + * @version $Revision: 1.4 $ * @since Horde 1.3 * @package Log */ @@ -27,9 +27,11 @@ * @param string $name The syslog facility. * @param string $ident The identity string. * @param array $conf The configuration array. + * @param int $maxLevel Maximum level at which to log. * @access public */ - function Log_syslog($name, $ident = '', $conf = array()) + function Log_syslog($name, $ident = '', $conf = array(), + $maxLevel = LOG_DEBUG) { // bc compatibilty if( 0 == count( $conf )) { @@ -37,6 +39,7 @@ } $this->name = $name; $this->_ident = $ident; + $this->_maxLevel = $maxLevel; } /** @@ -78,6 +81,9 @@ */ function log($message, $priority = LOG_INFO) { + /* Abort early if the priority is above the maximum logging level. */ + if ($priority > $this->_maxLevel) return; + if (!$this->_opened) { $this->open(); }