当前位置: 首页>>代码示例>>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;未经允许,请勿转载。