Example #1
0
 public static function setLogger($addMockWriter = false)
 {
     self::$logger = new Zend_Log();
     if (self::$config->logging->level == 0) {
         self::$logger->addWriter(new Zend_Log_Writer_Null(APP_DIR . '/log.txt'));
     } else {
         if (is_writable(self::$config->logging->location)) {
             $file = self::$config->logging->location;
         } else {
             if (!is_writable(APP_DIR . DIRECTORY_SEPARATOR . self::$config->logging->location)) {
                 throw new Exception('Couldn\'t find log file, or maybe it\'s not writable');
             } else {
                 $file = APP_DIR . DIRECTORY_SEPARATOR . self::$config->logging->location;
             }
         }
         self::$logger->addWriter(new Zend_Log_Writer_Stream($file));
         if ($addMockWriter) {
             self::$mockLogger = new Zend_Log_Writer_Mock();
             self::$logger->addWriter(self::$mockLogger);
         }
     }
     self::$logger->addFilter(new Zend_Log_Filter_Priority((int) self::$config->logging->level));
     Zend_Registry::set('logger', self::$logger);
 }