本文整理匯總了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;
}
示例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;
}