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


PHP Zend_Log类代码示例

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


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

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

示例2: addItem

 public static function addItem($message, $error = false)
 {
     global $s1b;
     if (self::getConfig()->getTracesEnabled() || self::getConfig()->getLogsEnabled()) {
         if (!strlen(trim($message))) {
             throw new \Exception('Cannot insert empty trace.');
         }
         // Ecriture du message dans le tableau des items en sessions si traces activées
         if (self::getConfig()->getTracesEnabled()) {
             self::initItems();
             self::$items[] = $message;
         }
         // Ecriture du log si activé
         if (self::getConfig()->getLogsEnabled()) {
             // vérification de l'existence du fichier et création si non existant
             $now = new \DateTime();
             $logFilePath = self::getContext()->getBaseDirectory() . sprintf("/var/log/%s-log.txt", $now->format("Ymd"));
             if (!file_exists($logFilePath)) {
                 $file = fopen($logFilePath, "w");
                 fclose($file);
             }
             // ecriture du log dans le fichier
             $writer = new \Zend_Log_Writer_Stream($logFilePath);
             $logger = new \Zend_Log($writer);
             if ($error) {
                 $logger->err($message);
             } else {
                 $logger->info($message);
             }
             $logger = null;
         }
     }
 }
开发者ID:berliozd,项目名称:cherbouquin,代码行数:33,代码来源:Trace.php

示例3: _initFirebugLog

 /**
  * Inicializa o logger do Firebug
  */
 protected function _initFirebugLog()
 {
     $logger = new Zend_Log();
     $writerFirebug = new Zend_Log_Writer_Firebug();
     $logger->addWriter($writerFirebug);
     Zend_Registry::set('logger', $logger);
 }
开发者ID:nidorx,项目名称:Zend_Dao_Vo,代码行数:10,代码来源:Bootstrap.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

 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

示例6: _initLogs

 protected function _initLogs()
 {
     $logger = new Zend_Log();
     $fireBugWriter = new Zend_Log_Writer_Firebug();
     $logger->addWriter($fireBugWriter);
     Zend_Registry::set('logger', $logger);
 }
开发者ID:BGCX261,项目名称:zieli-svn-to-git,代码行数:7,代码来源:Bootstrap.php

示例7: _initLogger

 /**
  * Init for the logger.
  *
  */
 protected function _initLogger()
 {
     $logger = new Zend_Log();
     $writer = new Zend_Log_Writer_Stream(APPLICATION_PATH . '/../log/' . $this->_config->log->file);
     $logger->addWriter($writer);
     Zend_Registry::set('log', $logger);
 }
开发者ID:noon,项目名称:phpMyBirthday,代码行数:11,代码来源:Bootstrap.php

示例8: preDispatch

 /**
  * (non-PHPdoc)
  * @see Zend_Controller_Plugin_Abstract::preDispatch()
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     try {
         $layout = Zend_Layout::getMvcInstance()->getLayout();
         $boostrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
         $userAgent = $boostrap->getResource('useragent');
         $device = $userAgent->getDevice();
         $mdlSkin = new System_Model_Skin();
         $skin = $mdlSkin->getSkinSelected();
         $skinName = is_null($skin) ? 'default' : strtolower($skin->name);
         $vr = Zend_Controller_Action_HelperBroker::getStaticHelper('Layout');
         $view = $vr->getView();
         $skinData = new Zend_Config_Xml('./skins/' . $skinName . '/skin.xml');
         # css files
         $stylesheet = (int) $device->getFeature('is_desktop') == 1 ? $skinData->files->stylesheet : $skinData->files->stylesheetMobile;
         $view->headLink()->prependStylesheet($view->baseUrl() . '/skins/' . $skinName . '/css/' . $stylesheet);
         $view->headLink()->headLink(array('rel' => 'favicon', 'href' => $view->baseUrl() . '/skins/' . $skinName . '/favicon.ico'), 'PREPEND');
         Zend_Registry::set('skin', $skinName);
         # javascript files
         $jsfiles = $skinData->files->js->toArray();
         foreach ($jsfiles as $js) {
             $view->headScript()->prependFile($view->baseUrl() . '/skins/' . $skinName . '/js/' . $js);
         }
     } catch (Exception $e) {
         try {
             $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugins.log');
             $logger = new Zend_Log($writer);
             $logger->log($e->getMessage(), Zend_Log::ERR);
         } catch (Exception $e) {
         }
     }
 }
开发者ID:rogercastaneda,项目名称:owlsys,代码行数:36,代码来源:Skin.php

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

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

示例11: 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 . '/mailer.log');
     $logger = new Zend_Log();
     $logger->addWriter(new Zend_Log_Writer_Stream($path));
     return $logger;
 }
开发者ID:omusico,项目名称:logica,代码行数:12,代码来源:MailerLog.php

示例12: preDispatch

 /**
  * Check the application.ini file for security settings.
  * If the url requires being secured, rebuild a secure url
  * and redirect.
  *
  * @param Zend_Controller_Request_Abstract $request            
  * @return void
  * @author Travis Boudreaux
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     try {
         $shouldSecureUrl = false;
         $options = Zend_Registry::getInstance()->get('options');
         // ar_dump($options['ssl'][$request->module][$request->controller][$request->action]['require_ssl']);
         // ie();
         // f (APPLICATION_ENV == ENV_PRODUCTION ) {
         // check configuration file for one of three require_ssl directives
         // secure an entire module with modules.module_name.require_ssl =
         // true
         // secure an entire controller with
         // modules.module_name.controller_name.require_ssl = true
         // secure an action with
         // modules.module_name.controller_name.action_name.require_ssl =
         // true
         if (@$options['ssl'][$request->module]['require_ssl'] || @$options['ssl'][$request->module][$request->controller]['require_ssl'] || @$options['ssl'][$request->module][$request->controller][$request->action]['require_ssl']) {
             $shouldSecureUrl = true;
         }
         if ($shouldSecureUrl) {
             $this->_secureUrl($request, true);
         } else {
             $this->_secureUrl($request, false);
         }
         //
     } catch (Exception $e) {
         try {
             $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugins.log');
             $logger = new Zend_Log($writer);
             $logger->log($e->getMessage(), Zend_Log::ERR);
         } catch (Exception $e) {
         }
     }
 }
开发者ID:rogercastaneda,项目名称:owlsys,代码行数:43,代码来源:Ssl.php

示例13: preDispatch

 /**
  * PreDispatch method for ACL Plugin. It checks if current user has privileges for resources requested 
  * @see Zend_Controller_Plugin_Abstract::preDispatch()
  * @param Zend_Controller_Request_Abstract $request 
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     try {
         $module = strtolower($request->getParam('module'));
         $controller = strtolower($request->getParam('controller'));
         $action = strtolower($request->getParam('action'));
         $resource = $module . ":" . $controller;
         $acl = Zend_Registry::get('ZendACL');
         $auth = Zend_Auth::getInstance();
         $identity = $auth->getIdentity();
         $roleID = $auth->hasIdentity() ? $auth->getIdentity()->role_id : 3;
         #var_dump($acl->isAllowed( $roleID, $resource, $action), $roleID, $resource, $action);
         #Zend_Debug::dump($module, $controller, $action, $roleID, $acl);
         #die();
         $redirector = Zend_Controller_Action_HelperBroker::getStaticHelper('redirector');
         if ($acl->isAllowed($roleID, $resource, $action) != true) {
             $redirector->gotoUrl('logout')->redirectAndExit();
         } else {
             return;
         }
     } catch (Exception $e) {
         try {
             $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugins.log');
             $logger = new Zend_Log($writer);
             $logger->log($e->getMessage(), Zend_Log::ERR);
         } catch (Exception $e) {
         }
     }
 }
开发者ID:rogercastaneda,项目名称:owlsys,代码行数:34,代码来源:Aclrouter.php

示例14: startLog

 protected function startLog()
 {
     $writer = new \Zend_Log_Writer_Stream('php://stdout');
     $logger = new \Zend_Log($writer);
     $logger->addPriority("sql", 8);
     $this->config->log = $logger;
 }
开发者ID:amptools-net,项目名称:midori-php,代码行数:7,代码来源:Boot.php

示例15: errorAction

 public function errorAction()
 {
     $http_accept = $_SERVER['HTTP_ACCEPT'];
     $this->_redirecUnknownImage($http_accept);
     $errors = $this->_getParam('error_handler');
     $msg = $errors->exception->getMessage();
     $backTrace = $errors->exception->getTraceAsString();
     $this->_handleMessage($errors);
     $this->_helper->viewRenderer->setViewScriptPathSpec('error/' . $this->getResponse()->getHttpResponseCode() . '.:suffix');
     $this->view->exception = $errors->exception;
     $this->view->request = $errors->request;
     $this->view->ui = 1;
     $logPath = realpath(APPLICATION_PATH . '/../log') . "/error";
     if (!is_dir($logPath)) {
         mkdir($logPath, 755, TRUE);
     }
     $log = new Zend_Log(new Zend_Log_Writer_Stream($logPath . "/" . date("Ymd") . "_applicationException.log"));
     $params1 = $this->_request->getParams();
     unset($params1["error_handler"]);
     $params = Zend_Json::encode($params1);
     $messages = array($msg, $backTrace, $params, "HTTP_ACCEPT: " . $http_accept, "");
     $log->err(implode(self::LOG_EOL, $messages));
     try {
         self::$_dispatcher->notify(new sfEvent($this, 'error.log', array('message' => array($msg, $backTrace), 'priority' => 3)));
         return;
     } catch (Exception $e) {
         echo $e->getMessage();
     }
 }
开发者ID:kangza,项目名称:hagtag,代码行数:29,代码来源:ErrorController.php


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