本文整理汇总了PHP中xPDO::_log方法的典型用法代码示例。如果您正苦于以下问题:PHP xPDO::_log方法的具体用法?PHP xPDO::_log怎么用?PHP xPDO::_log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xPDO
的用法示例。
在下文中一共展示了xPDO::_log方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _log
/**
* Provides modX the ability to use modRegister instances as log targets.
*
* {@inheritdoc}
*/
protected function _log($level, $msg, $target = '', $def = '', $file = '', $line = '')
{
if (empty($target)) {
$target = $this->logTarget;
}
$targetOptions = array();
if (is_array($target)) {
if (isset($target['options'])) {
$targetOptions = $target['options'];
}
$target = isset($target['target']) ? $target['target'] : 'ECHO';
}
if (is_object($target) && $target instanceof modRegister) {
if ($level === modX::LOG_LEVEL_FATAL) {
if (empty($file)) {
$file = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : (isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '');
}
$this->_logInRegister($target, $level, $msg, $def, $file, $line);
$this->sendError('fatal');
}
if ($this->_debug === true || $level <= $this->logLevel) {
if (empty($file)) {
$file = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : (isset($_SERVER['SCRIPT_FILENAME']) ? $_SERVER['SCRIPT_FILENAME'] : '');
}
$this->_logInRegister($target, $level, $msg, $def, $file, $line);
}
} else {
if ($level === modX::LOG_LEVEL_FATAL) {
while (@ob_end_clean()) {
}
if ($target == 'FILE' && ($cacheManager = $this->getCacheManager())) {
$filename = isset($targetOptions['filename']) ? $targetOptions['filename'] : 'error.log';
$filepath = isset($targetOptions['filepath']) ? $targetOptions['filepath'] : $this->getCachePath() . xPDOCacheManager::LOG_DIR;
$cacheManager->writeFile($filepath . $filename, '[' . strftime('%Y-%m-%d %H:%M:%S') . '] (' . $this->_getLogLevel($level) . $def . $file . $line . ') ' . $msg . "\n" . ($this->getDebug() === true ? '<pre>' . "\n" . print_r(debug_backtrace(), true) . "\n" . '</pre>' : ''), 'a');
}
$this->sendError('fatal');
}
parent::_log($level, $msg, $target, $def, $file, $line);
}
}