本文整理汇总了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;
}