コード例 #1
0
ファイル: Syslog.php プロジェクト: lerre/framework
 /**
  * Initialize syslog / set ident and facility
  *
  * @param  string  $ident         ident
  * @param  string  $facility      syslog facility
  * @return void
  */
 protected function _initializeSyslog()
 {
     self::$_lastIdent = $this->_options['ident'];
     self::$_lastFacility = $this->_options['facility'];
     if (!openlog($this->_options['ident'], $this->_options['openlogOptions'], $this->_options['facility'])) {
         throw new Horde_Log_Exception('Unable to open syslog');
     }
 }
コード例 #2
0
ファイル: Logger.php プロジェクト: horde/horde
 /**
  */
 public function create(Horde_Injector $injector)
 {
     global $conf;
     $this->error = null;
     /* Default handler. */
     if (empty($conf['log']['enabled'])) {
         return new Horde_Core_Log_Logger(new Horde_Log_Handler_Null());
     }
     switch ($conf['log']['type']) {
         case 'file':
         case 'stream':
             $append = $conf['log']['type'] == 'file' ? $conf['log']['params']['append'] ? 'a+' : 'w+' : null;
             $format = isset($conf['log']['params']['format']) ? $conf['log']['params']['format'] : 'default';
             switch ($format) {
                 case 'custom':
                     $formatter = new Horde_Log_Formatter_Simple(array('format' => $conf['log']['params']['template']));
                     break;
                 case 'default':
                 default:
                     // Use Horde_Log defaults.
                     $formatter = null;
                     break;
                 case 'xml':
                     $formatter = new Horde_Log_Formatter_Xml();
                     break;
             }
             try {
                 $handler = new Horde_Log_Handler_Stream($conf['log']['name'], $append, $formatter);
             } catch (Horde_Log_Exception $e) {
                 $this->error = $e;
                 return new Horde_Core_Log_Logger(new Horde_Log_Handler_Null());
             }
             try {
                 $handler->setOption('ident', $conf['log']['ident']);
             } catch (Horde_Log_Exception $e) {
             }
             break;
         case 'syslog':
             try {
                 $handler = new Horde_Log_Handler_Syslog();
                 if (!empty($conf['log']['name'])) {
                     $handler->setOption('facility', $conf['log']['name']);
                 }
                 if (!empty($conf['log']['ident'])) {
                     $handler->setOption('ident', $conf['log']['ident']);
                 }
             } catch (Horde_Log_Exception $e) {
                 $this->error = $e;
                 return new Horde_Core_Log_Logger(new Horde_Log_Handler_Null());
             }
             break;
         case 'null':
         default:
             // Use default null handler.
             return new Horde_Core_Log_Logger(new Horde_Log_Handler_Null());
     }
     switch ($conf['log']['priority']) {
         case 'WARNING':
             // Bug #12109
             $priority = 'WARN';
             break;
         default:
             $priority = defined('Horde_Log::' . $conf['log']['priority']) ? $conf['log']['priority'] : 'NOTICE';
             break;
     }
     $handler->addFilter(constant('Horde_Log::' . $priority));
     try {
         /* Horde_Core_Log_Logger contains code to format the log
          * message. */
         $ob = new Horde_Core_Log_Logger($handler);
         self::processQueue($ob);
         return $ob;
     } catch (Horde_Log_Exception $e) {
         $this->error = $e;
         return new Horde_Core_Log_Logger(new Horde_Log_Handler_Null());
     }
 }