當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Zend_Log_Writer_Stream::setFormatter方法代碼示例

本文整理匯總了PHP中Zend_Log_Writer_Stream::setFormatter方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Log_Writer_Stream::setFormatter方法的具體用法?PHP Zend_Log_Writer_Stream::setFormatter怎麽用?PHP Zend_Log_Writer_Stream::setFormatter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Log_Writer_Stream的用法示例。


在下文中一共展示了Zend_Log_Writer_Stream::setFormatter方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setup

 /**
  * Setup db
  *
  */
 public function setup(Zend_Config $config)
 {
     // Get resource config
     $writerConfig = $config->writer;
     $filterConfig = $config->filter;
     // Log instance
     $log = new Zend_Log();
     // Enable database writer?
     if ($writerConfig->database->enabled) {
         $db = $this->getRegistry()->get($writerConfig->database->key, 'Zend_Db_Adapter_Abstract');
         // Make sure it's a right object
         if (!$db instanceof Zend_Db_Adapter_Abstract) {
             require_once 'Zym/App/Resource/Exception.php';
             throw new Zym_App_Resource_Exception('Resource ' . get_class($this) . ' requires the internal registry item "db" to contain a Zend_Db_Adapter_Abstract object');
         }
         $dbWriter = new Zend_Log_Writer_Db($db, $writerConfig->database->table);
         $log->addWriter($dbWriter);
     }
     // Enable stream writer?
     if ($writerConfig->stream->enabled) {
         $streamWriter = new Zend_Log_Writer_Stream($writerConfig->stream->stream, $writerConfig->stream->mode);
         $streamWriter->setFormatter(new Zend_Log_Formatter_Simple('%timestamp% %ipAddr% %priorityName% (%priority%): %message%' . PHP_EOL));
         $log->addWriter($streamWriter);
     }
     // Enable null writer
     $log->addWriter(new Zend_Log_Writer_Null());
     // Setup filters
     // Priority filter
     if ($filterConfig->priority->enabled) {
         $log->addFilter(new Zend_Log_Filter_Priority((int) $filterConfig->priority->level));
     }
     // Setup events
     // Log user ip address
     //$log->setEventItem('ipAddr', $_SERVER['REMOTE_ADDR']);
 }
開發者ID:BGCX262,項目名稱:zym-svn-to-git,代碼行數:39,代碼來源:Log.php

示例2: addWriteToScreen

	function addWriteToScreen()
	{
		parent::addWriteToScreen();
		$writerScreen = new Zend_Log_Writer_Stream('php://stderr');
		$writerScreen->setFormatter( $this->screenFormatter );
		$this->addWriter($writerScreen);
	}
開發者ID:BackupTheBerlios,項目名稱:oos-svn,代碼行數:7,代碼來源:Exception.php

示例3: preDispatch

 public function preDispatch($request)
 {
     try {
         $locale = new Zend_Locale();
         $locale->setDefault('en');
         $locale->setLocale(Zend_Locale::BROWSER);
         $requestedLanguage = key($locale->getBrowser());
         $formatter = new Zend_Log_Formatter_Simple('%message%' . PHP_EOL);
         $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'translations.log');
         $writer->setFormatter($formatter);
         $logger = new Zend_Log($writer);
         $frontendOptions = array('cache_id_prefix' => 'translation', 'lifetime' => 86400, 'automatic_serialization' => true);
         $backendOptions = array('cache_dir' => APPLICATION_CACHE_PATH);
         $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions);
         $options = array('adapter' => 'gettext', 'scan' => Zend_Translate::LOCALE_FILENAME, 'content' => APPLICATION_PATH . '/languages/en/en.mo', 'locale' => 'auto', 'disableNotices' => true);
         $translate = new Zend_Translate($options);
         if (!$translate->isAvailable($locale->getLanguage())) {
             $locale->setLocale('en');
         } else {
             $translate->setLocale($locale);
         }
         $translate->setCache($cache);
         Zend_Registry::set('locale', $locale->getLanguage());
         Zend_Registry::set('Zend_Translate', $translate);
     } catch (Exception $e) {
         try {
             $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugin-locale.log');
             $logger = new Zend_Log($writer);
             $logger->log($e->getMessage(), Zend_Log::ERR);
         } catch (Exception $e) {
         }
     }
 }
開發者ID:rogercastaneda,項目名稱:owlsys,代碼行數:33,代碼來源:Locale.php

示例4: log

 private function log()
 {
     $dir = APP_PATH . '/logs/request';
     if (!is_dir($dir)) {
         mkdir($dir, 0755);
     }
     $file = $dir . '/' . date('Y-m-d') . '.log';
     $logger = new \Zend_Log();
     $formatter = new \Zend_Log_Formatter_Simple("%message%\n");
     $writer = new \Zend_Log_Writer_Stream($file);
     $writer->setFormatter($formatter);
     $logger->addWriter($writer);
     $data = array();
     $data[] = '[' . date('Y-m-d H:i:s') . '] ';
     $url = Http::getUrl('current');
     $url = substr($url, 0, strpos($url, '?')) . '?' . http_build_query($this->getRequest()->getRequest());
     $data[] = $url;
     $line = implode('', $data);
     $debug = Application::app()->getConfig()->debug;
     if ($debug) {
         $res = $this->getResponse()->getBody('api');
         $line .= "\n\t" . $res;
     }
     $logger->log($line, $logger::NOTICE);
 }
開發者ID:ares333,項目名稱:php-api-system,代碼行數:25,代碼來源:Index.php

示例5: initDefault

 public static function initDefault($logFilePath)
 {
     $writer = new Zend_Log_Writer_Stream($logFilePath);
     $format = '[%timestamp%] [%priorityName% %priority%] %message%' . PHP_EOL;
     $formatter = new Zend_Log_Formatter_Simple($format);
     $writer->setFormatter($formatter);
     Logger::registerLogger('default', $writer, null, true);
 }
開發者ID:uning,項目名稱:backend_common,代碼行數:8,代碼來源:Logger.php

示例6: addStreamWriter

 /**
  * Add a stream writer
  * 
  * @param array $params
  * @param object $formatter
  * @return void 
  */
 public function addStreamWriter($params = array(), Zend_Log_Formatter_Interface $formatter = null)
 {
     $writer = new Zend_Log_Writer_Stream($params['file_path_url'], $params['mode']);
     if ($formatter) {
         $writer->setFormatter($formatter);
     }
     $this->addWriter($writer);
 }
開發者ID:sarwarzahan,項目名稱:multi-logging,代碼行數:15,代碼來源:Log.php

示例7: initLogger

 /**
  * Initialise the logger with the given file.
  */
 private function initLogger($logfileName)
 {
     $logfile = @fopen($logfileName, 'a', false);
     $writer = new Zend_Log_Writer_Stream($logfile);
     $formatter = new Zend_Log_Formatter_Simple('%priorityName%: %message%' . PHP_EOL);
     $writer->setFormatter($formatter);
     $this->logger = new Zend_Log($writer);
 }
開發者ID:alexukua,項目名稱:opus4,代碼行數:11,代碼來源:MigrateSeriesCollections.php

示例8: getWriter

 private static function getWriter(Zend_Config $config)
 {
     if ($config->name === null) {
         return null;
     }
     $writer = null;
     switch ($config->name) {
         case "Zend_Log_Writer_Stream":
             if ($config->stream === null) {
                 return null;
             }
             if ($config->mode === null) {
                 $mode = 'a';
             }
             $writer = new Zend_Log_Writer_Stream($config->stream, $mode);
             break;
     }
     if ($writer !== null && $config->formatters !== null) {
         foreach ($config->formatters as $formatterConfig) {
             $formatter = self::getFormatter($formatterConfig);
             if ($formatter !== null) {
                 $writer->setFormatter($formatter);
             }
         }
     }
     if ($writer !== null && $config->formatters !== null) {
         foreach ($config->formatters as $formatterConfig) {
             $formatter = self::getFormatter($formatterConfig);
             if ($formatter !== null) {
                 $writer->setFormatter($formatter);
             }
         }
     }
     if ($writer !== null && $config->filters !== null) {
         foreach ($config->filters as $filterConfig) {
             $formatter = self::getFilter($filterConfig);
             if ($formatter !== null) {
                 $writer->addFilter($formatter);
             }
         }
     }
     return $writer;
 }
開發者ID:richhl,項目名稱:kalturaCE,代碼行數:43,代碼來源:KalturaLogFactory.php

示例9: _initLog

 /**
  * set logger
  * @return void
  */
 protected function _initLog()
 {
     // Error log
     $writer = new Zend_Log_Writer_Stream($this->_config->logpath);
     $format = '%timestamp% %priorityName% (%priority%): ' . '[%module%] [%controller%] %message%' . PHP_EOL;
     $formatter = new Zend_Log_Formatter_Simple($format);
     $writer->setFormatter($formatter);
     $logger = new Zend_Log($writer);
     Zend_Registry::getInstance()->set('logger', $logger);
 }
開發者ID:abtris,項目名稱:retreatin,代碼行數:14,代碼來源:Bootstrap.php

示例10: _allWriter

 /**
  * Writer untuk log message yang lainnya
  * Log message yang lainnya akan dituliskan ke dalam file system.log
  */
 protected function _allWriter()
 {
     $log = ROOT_DIR . '/data/log/system.log';
     $stream = fopen($log, 'a', false);
     if (!$stream) {
         throw new Exception('Failed to open _writer stream');
     }
     $writer = new Zend_Log_Writer_Stream($stream);
     $writer->setFormatter($this->_formatter);
     return $writer;
 }
開發者ID:hukumonline,項目名稱:pmg,代碼行數:15,代碼來源:Log.php

示例11: saveCdrBanners

 private function saveCdrBanners($datos, $id, $name)
 {
     $writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../logs/cdr/' . $name . ".banners");
     // $writer = new Zend_Log_Writer_Stream('/var/log/portalwap/'.$name.".banners");
     $formatter = new Zend_Log_Formatter_Simple('%message%' . PHP_EOL);
     $writer->setFormatter($formatter);
     $log = new Zend_Log($writer);
     $banners = 'banner1.' . $datos['url'][0] . "," . 'banner2.' . $datos['url'][1] . "," . 'banner3.' . $datos['url'][2] . "," . 'banner4.' . $datos['url'][3] . "," . 'banner5.' . $datos['url'][4];
     $mensaje = $datos['fecha'] . "," . $datos['hora'] . "," . $_SERVER['REMOTE_ADDR'] . "," . $datos['telefono'] . ",perfil:" . $datos['perfil'] . "," . $banners;
     $log->info($mensaje);
 }
開發者ID:josmel,項目名稱:PortalWapMovistar,代碼行數:11,代碼來源:Cdr.php

示例12: saveLog

 protected function saveLog($errors)
 {
     $logger = new Zend_Log();
     $writer = new Zend_Log_Writer_Stream('application/tmp/erro/error.xml');
     $formatter = new Zend_Log_Formatter_Xml();
     $writer->setFormatter($formatter);
     $logger->addWriter($writer);
     $exception = $errors->exception;
     $exception->getTraceAsString();
     $logger->debug($exception->getMessage() . "\r\n");
 }
開發者ID:erickosma,項目名稱:e-ong,代碼行數:11,代碼來源:ErrorController.php

示例13: saveCdrLog

 public function saveCdrLog($url, $message, $portal)
 {
     $datos = $this->obtenerPerfilNumero();
     $name = date('YmdH');
     $writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/cdr/' . $portal . '/' . $name . ".log");
     $formatter = new Zend_Log_Formatter_Simple('%message%' . PHP_EOL);
     $writer->setFormatter($formatter);
     $log = new Zend_Log($writer);
     $mensaje = $datos['fecha'] . "," . $datos['hora'] . "," . 'PERFIL:' . $datos['perfil'] . "," . $url . "," . $message . "," . $datos['telefono'];
     $log->info($mensaje);
 }
開發者ID:josmel,項目名稱:DevelEntelBipPe,代碼行數:11,代碼來源:ConfigPerfil.php

示例14: saveCdrDedicatorias

 public function saveCdrDedicatorias($resultado)
 {
     $name = date('YmdH');
     $datos = $this->registerCdr();
     $writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../logs/cdr/' . $name . ".dedicatoria");
     $formatter = new Zend_Log_Formatter_Simple('%message%' . PHP_EOL);
     $writer->setFormatter($formatter);
     $log = new Zend_Log($writer);
     $mensaje = $datos['fecha'] . "," . $datos['hora'] . "," . $_SERVER['REMOTE_ADDR'] . "," . $datos['telefono'] . "," . 'perfil:' . $datos['perfil'] . "," . $resultado;
     $log->info($mensaje);
 }
開發者ID:josmel,項目名稱:DevelEntretenimientoEntel,代碼行數:11,代碼來源:ConfigPerfil.php

示例15: _setupLog

 /**
  * Initialize the logger. You may want to override the function
  *
  * @return void
  */
 protected function _setupLog()
 {
     $this->logger = new Streamwide_Log();
     $this->logger->setEventItem("class", get_class($this));
     $writer = new Zend_Log_Writer_Stream("php://output");
     $format = "SW | %class% | %timestamp% | %pid% | %memory% | %duration% | %priorityName%: %message%<br/>" . PHP_EOL;
     $formater = new Zend_Log_Formatter_Simple($format);
     $writer->setFormatter($formater);
     //$writer->addFilter(new Streamwide_Log_Filter_Priority(LOGGER_INFO));
     $this->logger->addWriter($writer);
 }
開發者ID:cwcw,項目名稱:cms,代碼行數:16,代碼來源:Abstract.php


注:本文中的Zend_Log_Writer_Stream::setFormatter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。