Beispiel #1
0
 /**
  * Initialize handlers according to config
  * @return bool
  * @throws epExceptionLog
  * @access private
  */
 private function initialize()
 {
     // create the composite handler first
     if (!$this->composite_handler) {
         // create the composite handler
         $this->composite_handler =& epLib_Log::singleton('composite');
         if (!$this->composite_handler) {
             throw new epExceptionLog('Cannot instantiate composite handler');
             return false;
         }
     }
     // config the console hander (only on CLI)
     if (epIsCliRun()) {
         if ($this->getConfigOption('log_console')) {
             $this->console_handler =& epLib_Log::singleton('console', '', 'ident', array('stream' => STDOUT));
             if (!$this->console_handler) {
                 throw new epExceptionLog('Cannot instantiate log console handler');
                 return false;
             }
             $this->composite_handler->addChild($this->console_handler);
         }
     }
     // config the file hander
     $log_file = trim($this->getConfigOption('log_file'));
     if (!empty($log_file)) {
         $log_file = $this->getAbsolutePath($log_file);
         $this->file_handler =& epLib_Log::singleton('file', $log_file, 'ident', array('mode' => 0644));
         if (!$this->file_handler) {
             throw new epExceptionLog('Cannot instantiate log file handler');
             return false;
         }
         $this->composite_handler->addChild($this->file_handler);
     }
     return true;
 }