PEAR.php / Log.php
| From: | Roko Roic | Date: | Thu, 14 Feb 2002 09:37:03 +0000 |
| Subject: | PEAR.php / Log.php | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-4698@lists.php.net to get a copy of this message | ||
I hava a dilema on how to most efficiently use the PEAR Error logging
mechansim.
What I need is a package-wide system of throwing errors (db, query, user...)
and logging them into a file.
Currently I am using these classes from PEAR.
include_once('PEAR.php');
include_once('Log.php');
include_once('Log/file.php');
Every class in my package extends PEAR (not directly, but via a base package
class that 'extends PEAR') and initializes the error logging mechanism in
its constructor like this:
$this->PEAR();
$callback = array($this,'_logError'); // _logError is my error logging
method
$this->setErrorHandling(PEAR_ERROR_CALLBACK, $callback);
Each method returns a PEAR_Error on failure as such
return $this->raiseError($errstr, 0, null, null, $dbgstr);
and the baseclass::_logError is called which then logs the error
Is this the "proper way" of doing things. It seems a little bit of an
overhead to extend PEAR to my every class and even to initialize. Maybe I
needn't call $this->PEAR()? Do I?
I would like to keep the raiseError() functionality so that the logging
mechanism get called automatically.
Input is welcome.
Cheers
Roko Roic