当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Log::addWriter方法代码示例

本文整理汇总了PHP中Zend_Log::addWriter方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Log::addWriter方法的具体用法?PHP Zend_Log::addWriter怎么用?PHP Zend_Log::addWriter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Log的用法示例。


在下文中一共展示了Zend_Log::addWriter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _initLogging

 /**
  * Logging Initialization
  * KBBTODO:Move to application.ini
  * @return void
  */
 protected function _initLogging()
 {
     $this->_logging = new Zend_Log();
     if ($this->_config->kebab->logging->enable) {
         //Stream Writer
         if ($this->_config->kebab->logging->stream->enable) {
             $logFile = APPLICATION_PATH . '/variables/logs/application.log';
             $streamWriter = new Zend_Log_Writer_Stream($logFile);
             $this->_logging->addWriter($streamWriter);
         }
         //Firebug Writer
         if ($this->_config->kebab->logging->firebug->enable) {
             $firebugWriter = new Zend_Log_Writer_Firebug();
             $firebugWriter->setFormatter(new Zend_Log_Formatter_Simple());
             $this->_logging->addWriter($firebugWriter);
         }
     } else {
         //Empty Writer
         $nullWriter = new Zend_Log_Writer_Null();
         $this->_logging->addWriter($nullWriter);
     }
     Zend_Registry::set('logging', $this->_logging);
     // Info Log
     $this->_logging->log('Logging initialized...', Zend_Log::INFO);
     return $this->_logging;
 }
开发者ID:esironal,项目名称:kebab-project,代码行数:31,代码来源:Bootstrap.php

示例2: 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

示例3: __construct

 private function __construct()
 {
     // setup file error logging
     $file_writer = new Logger_Errorlog();
     if (Config::get_optional("DEBUG_LOG") == false) {
         $file_writer->addFilter(Zend_Log::INFO);
     }
     $log = new Zend_Log();
     $log->addWriter($file_writer);
     // setup email error logging
     if (Config::get_optional("log_to_email") == true) {
         $mail = new Zend_Mail();
         $mail->setFrom(Config::get_mandatory('log_email_from'));
         $mail->addTo(Config::get_mandatory('log_email_to'));
         // setup email template
         $layout = new Zend_Layout();
         $layout->setLayoutPath(DOCUMENT_ROOT . Config::get_mandatory("log_email_template"));
         $layout->setLayout('error-logger');
         $layout_formatter = new Zend_Log_Formatter_Simple('<li>.' . Zend_Log_Formatter_Simple::DEFAULT_FORMAT . '</li>');
         // Use default HTML layout.
         $email_writer = new Zend_Log_Writer_Mail($mail, $layout);
         $email_writer->setLayoutFormatter($layout_formatter);
         $email_writer->setSubjectPrependText(Config::get_mandatory('log_email_subject_prepend'));
         $email_writer->addFilter(Zend_Log::ERR);
         $log->addWriter($email_writer);
     }
     self::$logger = $log;
 }
开发者ID:ThibautLeger,项目名称:123-mini,代码行数:28,代码来源:Logger.php

示例4: getLogger

 public static function getLogger(Zend_Config $config = null)
 {
     $logger = new Zend_Log();
     $hasWriters = false;
     if ($config !== null && $config->writers !== null) {
         foreach ($config->writers as $writerConfig) {
             $writer = self::getWriter($writerConfig);
             if ($writer !== null) {
                 $logger->addWriter($writer);
                 $hasWriters = true;
             }
         }
     }
     if (!$hasWriters) {
         $logger->addWriter(new Zend_Log_Writer_Null());
     }
     // to turn off logging without making the logger throw exceptions
     if ($config !== null && $config->eventItems !== null) {
         foreach ($config->eventItems as $eventItemName => $eventItemClass) {
             $eventItemClass = (string) $eventItemClass;
             if (class_exists($eventItemClass)) {
                 $logger->setEventItem($eventItemName, new $eventItemClass());
             }
         }
     }
     return $logger;
 }
开发者ID:richhl,项目名称:kalturaCE,代码行数:27,代码来源:KalturaLogFactory.php

示例5: __construct

 public function __construct($enabled = false)
 {
     parent::__construct($enabled);
     $this->_log = new Zend_Log();
     $writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../data/log/db-queries.log');
     $this->_log->addWriter($writer);
 }
开发者ID:Webowiec,项目名称:zendnote,代码行数:7,代码来源:SqlLogger.php

示例6: getInstance

 /**
  * This method will instantiate the object, configure it and return it
  *
  * @return Zend_Cache_Manager
  */
 public static function getInstance()
 {
     $path = realpath(APPLICATION_PATH . '/../logs/' . CURRENT_MODULE . '/general.log');
     $logger = new Zend_Log();
     $logger->addWriter(new Zend_Log_Writer_Stream($path));
     if (!Zend_Registry::get('IS_PRODUCTION')) {
         $logger->addWriter(new Zend_Log_Writer_Firebug());
     }
     return $logger;
 }
开发者ID:omusico,项目名称:logica,代码行数:15,代码来源:GeneralLog.php

示例7: __construct

 /**
  * Class constructor
  *
  * Initialize a new Logging controller plugin
  */
 public function __construct()
 {
     if (!Zend_Registry::isRegistered('logger')) {
         $this->logger = new Zend_Log();
         $this->logger->addWriter(new Zend_Log_Writer_Stream(LOG_PATH . DIRECTORY_SEPARATOR . 'application.log'));
         Zend_Registry::set('logger', $this->logger);
     } else {
         $this->logger = Zend_Registry::get('logger');
     }
 }
开发者ID:humansky,项目名称:qframe,代码行数:15,代码来源:Log.php

示例8: factory

 /**
  * Factory to construct the Zend_Log and add writers based on the
  * configuration
  *
  * $config can be an array of an instance of Zend_Config
  *
  * @param mixed $config Array or instance of Zend_Config
  * @return Zend_Log
  */
 public static function factory($config = array())
 {
     // check config param
     if ($config instanceof Zend_Config) {
         $config = $config->toArray();
     } else {
         if (!is_array($config)) {
             throw new BazeZF_Framework_Log_Exception(sprintf('%s::%s first param must be an array or instance of Zend_Config', __CLASS__, __FUNC__));
         }
     }
     // Do we have one or more writers configured?
     if (!is_array(current($config))) {
         $config = array($config);
     }
     $logger = new Zend_Log();
     // load priority
     if (isset($config['priorities'])) {
         foreach ($config['priorities'] as $priorityName => $priority) {
             // convert priority const has integer
             if (!is_numeric($priority)) {
                 $priority = constant($priority);
             }
             $logger->addPriority($priorityName, (int) $priority);
         }
     }
     // load writers
     if (isset($config['writers'])) {
         foreach ($config['writers'] as $writer) {
             // skip disabled writer
             if (isset($writer['enable']) && !$writer['enable']) {
                 continue;
             }
             $writerObj = self::_loadWriter($writer['writerName'], isset($writer['writerParams']) ? $writer['writerParams'] : array());
             // load writer filters
             if (isset($writer['filterName'])) {
                 $filterObj = self::_loadFilter($writer['filterName'], isset($writer['filterParams']) ? $writer['filterParams'] : array());
                 $writerObj->addFilter($filterObj);
             }
             $logger->addWriter($writerObj);
         }
     }
     // load writer filters
     if (isset($config['filters'])) {
         foreach ($config['filters'] as $filter) {
             $filterObj = self::_loadFilter($filter['filterName'], isset($filter['filterParams']) ? $filter['filterParams'] : array());
             $logger->addFilter($filterObj);
         }
     }
     // add default writer if no writer was added
     if (!isset($writerObj)) {
         $writer = new Zend_Log_Writer_Null();
         $logger->addWriter($writer);
     }
     return $logger;
 }
开发者ID:rlecellier,项目名称:basezf,代码行数:64,代码来源:Log.php

示例9: getLog

 /**
  * @return Zend_Log
  */
 public function getLog()
 {
     if (null === $this->_log) {
         $log = new Zend_Log();
         $log->addWriter(new Zend_Log_Writer_Stream(WEB_ROOT . '/temporary/log/mail.log', 'a'));
         if ('development' == APPLICATION_ENV) {
             $log->addWriter(new Zend_Log_Writer_Firebug());
         }
         $this->_log = $log;
     }
     return $this->_log;
 }
开发者ID:nhochong,项目名称:qlkh-sgu,代码行数:15,代码来源:Mail.php

示例10: getWriters

 /**
  * Retrieve writers
  *
  * @param   array $writers
  * @return  void
  * @throws  Zend_Application_Resource_Exception
  */
 public function getWriters(array $writers = null)
 {
     foreach ($writers as $key => $value) {
         switch (strtolower($key)) {
             case 'stream':
                 if (!empty($value['path'])) {
                     $path = $value['path'];
                     $mode = 'a';
                     if (!empty($value['mode'])) {
                         $mode = $value['mode'];
                     }
                     $this->_log->addWriter(new Zend_Log_Writer_Stream($path, $mode));
                 }
                 break;
             case 'db':
                 // @todo Zend_Db writer support
                 require_once 'Zend/Application/Resource/Exception.php';
                 throw new Zend_Application_Resource_Exception('Unsupported 
                     writer.');
                 break;
             case 'doctrine':
                 if (!empty($value['modelClass'])) {
                     $columnMap = null;
                     if (!empty($value['columnMap'])) {
                         $columnMap = $value['columnMap'];
                     }
                     $modelClass = $value['modelClass'];
                     require_once 'Parables/Log/Writer/Doctrine.php';
                     $this->_log->addWriter(new Parables_Log_Writer_Doctrine($modelClass, $columnMap));
                 }
                 break;
             case 'email':
                 // @todo Email writer support
                 require_once 'Zend/Application/Resource/Exception.php';
                 throw new Zend_Application_Resource_Exception('Unsupported 
                     writer.');
                 break;
             case 'firebug':
                 $this->_log->addWriter(new Zend_Log_Writer_Firebug());
                 break;
             case 'mock':
                 $this->_log->addWriter(new Zend_Log_Writer_Mock());
                 break;
             case 'null':
                 $this->_log->addWriter(new Zend_Log_Writer_Null());
                 break;
             default:
                 require_once 'Zend/Application/Resource/Exception.php';
                 throw new Zend_Application_Resource_Exception('Invalid 
                     writer.');
         }
     }
 }
开发者ID:rockett,项目名称:parables,代码行数:60,代码来源:Log.php

示例11: _initMyLoggingSettings

 protected function _initMyLoggingSettings()
 {
     $logger = new Zend_Log();
     $logger->addFilter(new Zend_Log_Filter_Priority((int) $this->_options["logging"]["level"]));
     foreach ($this->_options["logging"]["writer"] as $wr) {
         if ($wr == "Zend_Log_Writer_Stream") {
             $w = new $wr($this->_options["logging"]["filename"]);
             $logger->addWriter($w);
         } else {
             $logger->addWriter(new $wr());
         }
     }
     Zend_Registry::set("logger", $logger);
 }
开发者ID:radalin,项目名称:zf-examples,代码行数:14,代码来源:Bootstrap.php

示例12: initLogger

 protected function initLogger()
 {
     $firebug = new Zend_Log_Writer_Firebug();
     $file = new Zend_Log_Writer_Stream(APPLICATION_PATH . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "log" . DIRECTORY_SEPARATOR . "log.txt", 'a+');
     $this->logger = new Zend_Log($firebug);
     $this->logger->addWriter($file);
 }
开发者ID:Velrok,项目名称:wg-organizer,代码行数:7,代码来源:ApplicationController.php

示例13: errorAction

 public function errorAction()
 {
     $errors = $this->_getParam('error_handler');
     $logger = new Zend_Log();
     $writer = new Zend_Log_Writer_Stream(dirname(APPLICATION_PATH) . '/logs/exceptions.log');
     $logger->addWriter($writer);
     //$logger->addWriter(new Keplin_Log_Writer_Email());
     switch ($errors->type) {
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
         case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
             // 404 error -- controller or action not found
             $this->getResponse()->setHttpResponseCode(404);
             $this->view->message = 'Page not found';
             $logger->log($errors->exception->getMessage(), Zend_Log::NOTICE);
             break;
         default:
             // application error
             $this->getResponse()->setHttpResponseCode(500);
             $this->view->message = 'Application error';
             if (get_class($errors->exception) == 'Keplin_ProhibitedException') {
                 $this->view->message = 'Access Prohibited.';
                 $logger->log($errors->exception->getMessage(), Zend_Log::WARN);
             } else {
                 $logger->log($errors->exception->getMessage(), Zend_Log::ERR);
             }
             break;
     }
     // conditionally display exceptions
     if ($this->getInvokeArg('displayExceptions') == true) {
         $this->view->exception = $errors->exception;
     }
     $this->view->request = $errors->request;
 }
开发者ID:kminkov,项目名称:Blog,代码行数:34,代码来源:ErrorController.php

示例14: initLog

 /**
  * Initialize a Zend style logger
  */
 public function initLog()
 {
     // Output to shell
     $writer = new Zend_Log_Writer_Stream('php://output');
     $writer->setFormatter(new Local_Shell_Formatter());
     $this->log = new Zend_Log($writer);
     // Log to file
     if (!$this->logFile) {
         $bits = explode('/', $GLOBALS['argv'][0]);
         $bits = explode('.', $bits[count($bits) - 1]);
         $this->logFile = 'shell_local_' . $bits[0] . '.log';
     }
     $logDir = Mage::getBaseDir('var') . DS . 'log';
     $logFile = $logDir . DS . $this->logFile;
     if (!is_dir($logDir)) {
         mkdir($logDir);
         chmod($logDir, 0777);
     }
     if (!file_exists($logFile)) {
         file_put_contents($logFile, '');
         chmod($logFile, 0777);
     }
     $writer = new Zend_Log_Writer_Stream($logFile);
     $format = '%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL;
     $formatter = new Zend_Log_Formatter_Simple($format);
     $writer->setFormatter($formatter);
     $this->log->addWriter($writer);
 }
开发者ID:Hevelop,项目名称:Magento-Shell,代码行数:31,代码来源:abstract.php

示例15: 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


注:本文中的Zend_Log::addWriter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。