本文整理汇总了PHP中think\Log::getLog方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::getLog方法的具体用法?PHP Log::getLog怎么用?PHP Log::getLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类think\Log
的用法示例。
在下文中一共展示了Log::getLog方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRecord
public function testRecord()
{
$record_msg = 'record';
Log::record($record_msg, 'notice');
$logs = Log::getLog();
$this->assertNotFalse(array_search(['type' => 'notice', 'msg' => $record_msg], $logs));
}
示例2: testRecord
public function testRecord()
{
$record_msg = 'record';
Log::record($record_msg, 'notice');
$logs = Log::getLog();
$this->assertNotFalse(array_search($record_msg, $logs['notice']));
}
示例3: testRecord
public function testRecord()
{
Log::clear();
Log::record('test');
$this->assertEquals([['type' => 'log', 'msg' => 'test']], Log::getLog());
Log::record('hello', 'info');
$this->assertEquals([['type' => 'log', 'msg' => 'test'], ['type' => 'info', 'msg' => 'hello']], Log::getLog());
Log::clear();
Log::info('test');
$this->assertEquals([['type' => 'info', 'msg' => 'test']], Log::getLog());
}
示例4: showTrace
/**
* 显示页面Trace信息
* @access private
*/
private function showTrace()
{
// 系统默认显示信息
$files = get_included_files();
$info = [];
foreach ($files as $key => $file) {
$info[] = $file . ' ( ' . number_format(filesize($file) / 1024, 2) . ' KB )';
}
$trace = [];
Debug::remark('START', NOW_TIME);
$base = ['请求信息' => date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . ' ' . $_SERVER['SERVER_PROTOCOL'] . ' ' . $_SERVER['REQUEST_METHOD'] . ' : ' . $_SERVER['PHP_SELF'], '运行时间' => Debug::getUseTime('START', 'END', 6) . 's', '内存开销' => MEMORY_LIMIT_ON ? G('START', 'END', 'm') . 'b' : '不支持', '查询信息' => N('db_query') . ' queries ' . N('db_write') . ' writes ', '文件加载' => count($files), '缓存信息' => N('cache_read') . ' gets ' . N('cache_write') . ' writes ', '配置加载' => count(Config::get())];
// 读取项目定义的Trace文件
$traceFile = MODULE_PATH . 'trace.php';
if (is_file($traceFile)) {
$base = array_merge($base, include $traceFile);
}
$debug = Log::getLog();
$tabs = Config::get('trace_page_tabs');
foreach ($tabs as $name => $title) {
switch (strtoupper($name)) {
case 'BASE':
// 基本信息
$trace[$title] = $base;
break;
case 'FILE':
// 文件信息
$trace[$title] = $info;
break;
default:
// 调试信息
$name = strtoupper($name);
if (strpos($name, '|')) {
// 多组信息
$array = explode('|', $name);
$result = [];
foreach ($array as $name) {
$result += isset($debug[$name]) ? $debug[$name] : [];
}
$trace[$title] = $result;
} else {
$trace[$title] = isset($debug[$name]) ? $debug[$name] : '';
}
}
}
unset($files, $info, $base, $debug);
// 调用Trace页面模板
ob_start();
include Config::has('tmpl_trace_file') ? Config::get('tmpl_trace_file') : THINK_PATH . 'tpl/page_trace.tpl';
return ob_get_clean();
}
示例5: trace
/**
* 记录日志信息
* @param mixed $log log信息 支持字符串和数组
* @param string $level 日志级别
* @return void|array
*/
function trace($log = '[think]', $level = 'log')
{
if ('[think]' === $log) {
return \think\Log::getLog();
} else {
\think\Log::record($log, $level);
}
}
示例6: inject
public static function inject(Response $response)
{
$config = Config::get('trace');
$type = isset($config['type']) ? $config['type'] : 'Html';
$request = Request::instance();
$accept = $request->header('accept');
$contentType = $response->getHeader('Content-Type');
$class = false !== strpos($type, '\\') ? $type : '\\think\\debug\\' . ucwords($type);
unset($config['type']);
if (class_exists($class)) {
$trace = new $class($config);
} else {
throw new ClassNotFoundException('class not exists:' . $class, $class);
}
if ($response instanceof Redirect) {
//TODO 记录
} else {
$output = $trace->output($response, Log::getLog());
if (is_string($output)) {
// trace调试信息注入
$content = $response->getContent();
$pos = strripos($content, '</body>');
if (false !== $pos) {
$content = substr($content, 0, $pos) . $output . substr($content, $pos);
} else {
$content = $content . $output;
}
$response->content($content);
}
}
}