Home > Archive > PHP Pear > June 2006 > Re: [PEAR] Log: setMask
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PEAR] Log: setMask
|
|
|
| Sabine wrote:
> Hello to all,
>
> I try to set a log-mask so that I only see emergency errors (for
> example). But I get all error messages.
> It must be very simple, but I don't see,what is wrong here:
>
> $colors = array( PEAR_LOG_CRIT => 'red'
> );
> $conf = array('title' => 'Test Logger',
> 'colors' => $colors
> );
> $logger = &Log::singleton('win', 'TestLog', $_SERVER['PHP_SELF'], $conf);
> function phpErrorHandler($code, $message, $file, $line)
> {
> global $logger;
> /* Map the PHP error to a Log priority. */
> switch ($code) {
> case E_WARNING:
> case E_USER_WARNING:
> $priority = PEAR_LOG_WARNING;
> break;
> case E_NOTICE:
> case E_USER_NOTICE:
> $priority = PEAR_LOG_NOTICE;
> break;
> case E_ERROR:
> case E_USER_ERROR:
> $priority = PEAR_LOG_ERR;
> break;
> default:
> $priotity = PEAR_LOG_INFO;
> }
> $logger->log('PHP: ' . $message . ' in ' . $file . ' at line ' . $line,
> $priority);
> }
> set_error_handler('phpErrorHandler');
>
> $mask = Log::MIN(PEAR_LOG_EMERG);
> $logger->setMask($mask);
> $logger->info("Test info");
> $m = 1/0;
>
> That is, what I get:
> Ident Priority Message
> 00:39:51.42 /logger_test.php Notice PHP: Undefined offset: 6
> in /usr/share/php/Log/win.php at line 246
> 00:39:51.42 /logger_test.php Info Test info
> 00:39:51.42 /logger_test.php Warning PHP: Division by zero
> in /logger_test.php at line 47
>
>
It should be:
$logger =& Log::singleton( ...
brian
| |
| Sabine 2006-06-27, 7:00 pm |
| Hello Brian,
thanks for your answer. But that seems not to be the point. The problem
persists.
Best regards
Sabine
brian schrieb:
> Sabine wrote:
>
> It should be:
>
> $logger =& Log::singleton( ...
>
> brian
>
| |
| Sabine 2006-06-27, 7:00 pm |
| Hello Brian,
thanks for your answer. But that seems not to be the point. The problem
persists.
Best regards
Sabine
brian schrieb:
> Sabine wrote:
>
> It should be:
>
> $logger =& Log::singleton( ...
>
> brian
>
| |
| Jörg Wegner 2006-06-27, 7:00 pm |
| Hello Sabine,
On Tuesday 27 June 2006 18:27, Sabine wrote:
[...][color=darkred]
try it this way, it should work for you
$mask =3D Log::UPTO(PEAR_LOG_EMERG);
[color=darkred]
Best regards
J=F6rg Wegner
=2D-=20
J=F6rg Wegner
E-Mail: wegner.joerg@gmx.de
| |
| Sabine 2006-06-27, 7:00 pm |
| Hello Jörg,
thanks for your answer.
I tried it with UPTO, too.
But everytime it is the same: every error, warnig, notice etc. is logged.
Is it possible that there is a bug in the log-script?
Best regards
Sabine
Jörg Wegner schrieb:
> Hello Sabine,
>
> On Tuesday 27 June 2006 18:27, Sabine wrote:
>
> [...]
>
>
> try it this way, it should work for you
> $mask = Log::UPTO(PEAR_LOG_EMERG);
>
>
>
> Best regards
> Jörg Wegner
>
|
|
|
|
|