Re: Log Diffs
| From: | Tomas V.V.Cox | Date: | Wed, 10 Jul 2002 18:09:03 +0000 |
| Subject: | Re: Log Diffs | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-7646@lists.php.net to get a copy of this message | ||
Michael Dransfield wrote:
>
> Please can someone apply these diffs (correct format this time :)
>
> They are for the LOG_* constants, to provide better logging in Win
> platforms
>
Why not just integrate pearToSys() in priorityToString()?
As that is not going to introduce any BC problems, I'll apply the patch
if I get no objections from Jon.
Tomas V.V.Cox
>
> __________________________________________________
> Do You Yahoo!?
> Sign up for SBC Yahoo! Dial - First Month Free
> http://sbc.yahoo.com
>
> ------------------------------------------------------------------------
> Index: pear/Log/Log.php
> ===================================================================
> RCS file: /repository/pear/Log/Log.php,v
> retrieving revision 1.8
> diff -u -r1.8 Log.php
> --- pear/Log/Log.php 29 Apr 2002 05:18:45 -0000 1.8
> +++ pear/Log/Log.php 10 Jul 2002 15:18:43 -0000
> @@ -45,6 +45,23 @@
> * @access private
> */
> var $_listeners = array();
> + /**
> + *
> + * Initialises the log defines the PEAR_ constants
> + *
> + * @access public
> + */
> +
> + function Log(){
> + define('PEAR_LOG_EMERG', 1);
> + define('PEAR_LOG_ALERT', 2);
> + define('PEAR_LOG_CRIT', 3);
> + define('PEAR_LOG_ERR', 4);
> + define('PEAR_LOG_WARNING', 5);
> + define('PEAR_LOG_NOTICE', 6);
> + define('PEAR_LOG_INFO', 7);
> + define('PEAR_LOG_DEBUG', 8);
> + }
>
>
> /**
> @@ -144,6 +161,15 @@
> function priorityToString($priority)
> {
> $priorities = array(
> + PEAR_LOG_EMERG => 'emergency',
> + PEAR_LOG_ALERT => 'alert',
> + PEAR_LOG_CRIT => 'critical',
> + PEAR_LOG_ERR => 'error',
> + PEAR_LOG_WARNING => 'warning',
> + PEAR_LOG_NOTICE => 'notice',
> + PEAR_LOG_INFO => 'info',
> + PEAR_LOG_DEBUG => 'debug',
> +
> LOG_EMERG => 'emergency',
> LOG_ALERT => 'alert',
> LOG_CRIT => 'critical',
> @@ -156,6 +182,29 @@
>
> return $priorities[$priority];
> }
> +
> +
> + /**
> + * Returns the LOG constant from PEAR_LOG constant (only needed for win32)
> + *
> + * @param int $priority A LOG_* / PEAR_LOG_* integer constant.
> + *
> + * @return int The LOG_* integer constant
> + */
> + function pearToSys($priority)
> + {
> + $priorities = array(
> + PEAR_LOG_EMERG => LOG_EMERG,
> + PEAR_LOG_ALERT => LOG_ALERT,
> + PEAR_LOG_CRIT => LOG_CRIT,
> + PEAR_LOG_ERR => LOG_ERR,
> + PEAR_LOG_WARNING => LOG_WARNING,
> + PEAR_LOG_NOTICE => LOG_NOTICE,
> + PEAR_LOG_INFO => LOG_INFO,
> + PEAR_LOG_DEBUG => LOG_DEBUG
> + );
> + return $priorities[$priority];
> + }
>
> /**
> * Adds a Log_observer instance to the list of observers that are be
>
> ------------------------------------------------------------------------
> Index: pear/Log/Log/syslog.php
> ===================================================================
> RCS file: /repository/pear/Log/Log/syslog.php,v
> retrieving revision 1.4
> diff -u -r1.4 syslog.php
> --- pear/Log/Log/syslog.php 29 Apr 2002 05:18:45 -0000 1.4
> +++ pear/Log/Log/syslog.php 10 Jul 2002 15:19:21 -0000
> @@ -88,7 +88,7 @@
> $this->open();
> }
>
> - syslog($priority, $message);
> + syslog(Log::pearToSys($priority), $message);
> $this->notifyAll(array('priority' => $priority, 'message'
> => $message));
> }
> }
>
> ------------------------------------------------------------------------
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php