protected function _initLog()
 {
     $log = new Zend_Log();
     // Non-production
     if (APPLICATION_ENV !== 'production') {
         $log->addWriter(new Zend_Log_Writer_Firebug());
     }
     // Production
     try {
         $log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/install.log'));
     } catch (Exception $e) {
         // Check directory
         if (!@is_dir(APPLICATION_PATH . '/temporary/log') && @mkdir(APPLICATION_PATH . '/temporary/log', 0777, true)) {
             $log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/install.log'));
         } else {
             // Silence ...
             if (APPLICATION_ENV !== 'production') {
                 $log->log($e->__toString(), Zend_Log::CRIT);
             } else {
                 // Make sure logging doesn't cause exceptions
                 $log->addWriter(new Zend_Log_Writer_Null());
             }
         }
     }
     Zend_Registry::set('Zend_Log', $log);
     Engine_Api::registerErrorHandlers();
     if ('production' != APPLICATION_ENV) {
         Engine_Exception::setLog($log);
     }
     return $log;
 }
 public function __construct($message = '', $code = 'UNKNOWN', Exception $previous = null)
 {
     $keys = self::getCodeKeys();
     if (in_array($code, $keys)) {
         $code = array_search($code, $keys);
     } else {
         if (isset($keys[$code])) {
             // Ok
         } else {
             if (is_numeric($code)) {
                 $code = (int) $code;
             } else {
                 $code = 0;
             }
         }
     }
     parent::__construct($message, $code, $previous);
 }
 /**
  * Set the exception logger
  * 
  * @param Zend_Log $log
  */
 public static function setLog(Zend_Log $log = null)
 {
     self::$_log = $log;
 }
示例#4
0
 protected function _initLog()
 {
     $log = new Zend_Log();
     try {
         $log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/install.log'));
     } catch (Exception $e) {
         $log->addWriter(new Zend_Log_Writer_Null());
     }
     // Non-production
     if (APPLICATION_ENV !== 'production') {
         $log->addWriter(new Zend_Log_Writer_Firebug());
     }
     Zend_Registry::set('Zend_Log', $log);
     Engine_Api::registerErrorHandlers();
     if ('production' != APPLICATION_ENV) {
         Engine_Exception::setLog($log);
     }
     return $log;
 }
示例#5
0
 protected function _initLog()
 {
     $log = new Zend_Log();
     $log->setEventItem('domain', 'error');
     // Non-production
     if (APPLICATION_ENV !== 'production') {
         $log->addWriter(new Zend_Log_Writer_Firebug());
     }
     // Get log config
     $db = Engine_Db_Table::getDefaultAdapter();
     $logAdapter = $db->select()->from('engine4_core_settings', 'value')->where('`name` = ?', 'core.log.adapter')->query()->fetchColumn();
     // Set up log
     switch ($logAdapter) {
         case 'database':
             try {
                 $log->addWriter(new Zend_Log_Writer_Db($db, 'engine4_core_log'));
             } catch (Exception $e) {
                 // Make sure logging doesn't cause exceptions
                 $log->addWriter(new Zend_Log_Writer_Null());
             }
             break;
         default:
         case 'file':
             try {
                 $log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/main.log'));
             } catch (Exception $e) {
                 // Check directory
                 if (!@is_dir(APPLICATION_PATH . '/temporary/log') && @mkdir(APPLICATION_PATH . '/temporary/log', 0777, true)) {
                     $log->addWriter(new Zend_Log_Writer_Stream(APPLICATION_PATH . '/temporary/log/main.log'));
                 } else {
                     // Silence ...
                     if (APPLICATION_ENV !== 'production') {
                         $log->log($e->__toString(), Zend_Log::CRIT);
                     } else {
                         // Make sure logging doesn't cause exceptions
                         $log->addWriter(new Zend_Log_Writer_Null());
                     }
                 }
             }
             break;
         case 'none':
             $log->addWriter(new Zend_Log_Writer_Null());
             break;
     }
     // Save to registry
     Zend_Registry::set('Zend_Log', $log);
     // Register error handlers
     Engine_Api::registerErrorHandlers();
     if ('production' != APPLICATION_ENV) {
         Engine_Exception::setLog($log);
     }
     return $log;
 }