I am trying to make my own custom logger but the write method gets called 
twice oddly enough. Here is the code I am using

DatabaseLogger.php in the Lib/Engine/ directory:

App::uses('CakeLogInterface', 'Log');
>
>
>> class DatabaseLogger implements CakeLogInterface {
>
>  private $types = array();
>
>      public function __construct($options = array()) {
>
> // Allowed method calls
>
> $this->types = $options['types'];
>
>     }
>
>
>>     public function write($type = NULL, $message = NULL) {
>
>
>> // Only store to cache types that are permitted, other errors from cake 
>> are not reported
>
> if(!empty($this->types) && in_array($type, $this->types))
>
> {
>
>     //make database entry here
>
> }
>
>     } 
>
> }
>
>
 Here is my core.php setup:


/**
>
>  * Configures default file logging options
>
>  */
>
> App::uses('CakeLog', 'Log');
>
> CakeLog::config('debug', array(
>
> 'engine' => 'FileLog',
>
> 'types' => array('notice', 'info', 'debug'),
>
> 'file' => 'debug',
>
> ));
>
> CakeLog::config('error', array(
>
> 'engine' => 'FileLog',
>
> 'types' => array('warning', 'error', 'critical', 'alert', 'emergency'),
>
> 'file' => 'error',
>
> ));
>
>
>> // Custom configuration for Couchbase error loggin
>
> CakeLog::config('mytest', array(
>
>     'engine' => 'DatabaseLogger',
>
> 'types' => array('mytest'),
>
> 'scope' => array(),
>
> 'file' => '',
>
> ));
>
>
To use my log I call the method like so:

CakeLog::write('mytest', 'this message!');
>


Oddly enough if I put a debug statement in the code for the DatabaseLogger 
it stop. I have no idea why it does that. Can anyone please help me 
understand why this is getting called twice?

thanks in advance 
 

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/cake-php?hl=en.


Reply via email to