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


PHP CakeLog::getInstance方法代碼示例

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


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

示例1: write

 /**
  * Writes the given message and type to all of the configured log adapters.
  * Configured adapters are passed both the $type and $message variables. $type
  * is one of the following strings/values.
  *
  * ### Types:
  *
  * - `LOG_WARNING` => 'warning',
  * - `LOG_NOTICE` => 'notice',
  * - `LOG_INFO` => 'info',
  * - `LOG_DEBUG` => 'debug',
  * - `LOG_ERR` => 'error',
  * - `LOG_ERROR` => 'error'
  *
  * ### Usage:
  *
  * Write a message to the 'warning' log:
  *
  * `CakeLog::write('warning', 'Stuff is broken here');`
  *
  * @param string $type
  *        	Type of message being written
  * @param string $message
  *        	Message content to log
  * @return boolean Success
  * @access public
  * @static
  *
  */
 function write($type, $message)
 {
     if (!defined('LOG_ERROR')) {
         define('LOG_ERROR', 2);
     }
     if (!defined('LOG_ERR')) {
         define('LOG_ERR', LOG_ERROR);
     }
     $levels = array(LOG_WARNING => 'warning', LOG_NOTICE => 'notice', LOG_INFO => 'info', LOG_DEBUG => 'debug', LOG_ERR => 'error', LOG_ERROR => 'error');
     if (is_int($type) && isset($levels[$type])) {
         $type = $levels[$type];
     }
     $self =& CakeLog::getInstance();
     if (empty($self->_streams)) {
         $self->_autoConfig();
     }
     $keys = array_keys($self->_streams);
     foreach ($keys as $key) {
         $logger =& $self->_streams[$key];
         $logger->write($type, $message);
     }
     return true;
 }
開發者ID:arendasistemasintegrados,項目名稱:mateusleme,代碼行數:52,代碼來源:cake_log.php

示例2: write

 /**
  * Writes the given message and type to all of the configured log adapters.
  * Configured adapters are passed both the $type and $message variables. $type
  * is one of the following strings/values.
  *
  * ### Types:
  *
  * - `LOG_WARNING` => 'warning',
  * - `LOG_NOTICE` => 'notice',
  * - `LOG_INFO` => 'info',
  * - `LOG_DEBUG` => 'debug',
  * - `LOG_ERR` => 'error',
  * - `LOG_ERROR` => 'error'
  *
  * ### Usage:
  *
  * Write a message to the 'warning' log:
  * 
  * `CakeLog::write('warning', 'Stuff is broken here');`
  *
  * @param string $type Type of message being written
  * @param string $message Message content to log
  * @return boolean Success
  * @access public
  * @static
  */
 function write($type, $message)
 {
     if (!defined('LOG_ERROR')) {
         define('LOG_ERROR', 2);
     }
     if (!defined('LOG_ERR')) {
         define('LOG_ERR', LOG_ERROR);
     }
     if (Configure::read('Database_log') === true) {
         $settings = array('class' => 'SystemLog', 'alias' => 'SystemLog', 'table' => 'system_logs', 'ds' => 'default');
         ClassRegistry::init($settings);
         $SystemLogModel =& ClassRegistry::getObject('SystemLog');
     }
     $levels = array(LOG_WARNING => 'warning', LOG_NOTICE => 'notice', LOG_INFO => 'info', LOG_DEBUG => 'debug', LOG_ERR => 'error', LOG_ERROR => 'error');
     if (is_int($type) && isset($levels[$type])) {
         $type = $levels[$type];
     }
     $self =& CakeLog::getInstance();
     if (empty($self->_streams)) {
         $self->_autoConfig();
     }
     $keys = array_keys($self->_streams);
     foreach ($keys as $key) {
         $logger =& $self->_streams[$key];
         $logger->write($type, $message);
         if (isset($SystemLogModel) && !empty($SystemLogModel)) {
             $SystemLog_data = array('id' => 0, 'type' => $type, 'log_text' => $message);
             $SystemLogModel->save($SystemLog_data);
         }
     }
     return true;
 }
開發者ID:hobbysh,項目名稱:seevia-frameworks,代碼行數:58,代碼來源:cake_log.php


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