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


PHP Log::getLog方法代碼示例

本文整理匯總了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));
 }
開發者ID:Lofanmi,項目名稱:think,代碼行數:7,代碼來源:fileTest.php

示例2: testRecord

 public function testRecord()
 {
     $record_msg = 'record';
     Log::record($record_msg, 'notice');
     $logs = Log::getLog();
     $this->assertNotFalse(array_search($record_msg, $logs['notice']));
 }
開發者ID:top-think,項目名稱:framework,代碼行數:7,代碼來源:fileTest.php

示例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());
 }
開發者ID:Lofanmi,項目名稱:think,代碼行數:11,代碼來源:logTest.php

示例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();
 }
開發者ID:houseme,項目名稱:think,代碼行數:54,代碼來源:show_page_trace.php

示例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);
    }
}
開發者ID:yuhongjie,項目名稱:think,代碼行數:14,代碼來源:helper.php

示例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);
         }
     }
 }
開發者ID:GDdark,項目名稱:cici,代碼行數:31,代碼來源:Debug.php


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