<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                [TOC] * * * * * ## 1 日志文件源代碼(thinkphp/library/think/Log.php) ~~~ class Log { const LOG = 'log'; const ERROR = 'error'; const INFO = 'info'; const SQL = 'sql'; const NOTICE = 'notice'; const ALERT = 'alert'; protected static $log = []; protected static $type = ['log', 'error', 'info', 'sql', 'notice', 'alert']; protected static $driver = null; protected static $alarm = null; public static function init($config = []) { $type = isset($config['type']) ? $config['type'] : 'File'; $class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\log\\driver\\') . ucwords($type); unset($config['type']); self::$driver = new $class($config); APP_DEBUG && Log::record('[ LOG ] INIT ' . $type . ': ' . var_export($config, true), 'info'); } public static function alarm($config = []) { $type = isset($config['type']) ? $config['type'] : 'Email'; $class = (!empty($config['namespace']) ? $config['namespace'] : '\\think\\log\\alarm\\') . ucwords($type); unset($config['type']); self::$alarm = new $class($config['alarm']); APP_DEBUG && Log::record('[ CACHE ] ALARM ' . $type . ': ' . var_export($config, true), 'info'); } public static function getLog() { return self::$log; } public static function record($msg, $type = 'log') { if (!is_string($msg)) { $msg = var_export($msg, true); } self::$log[] = ['type' => $type, 'msg' => $msg]; } public static function clear() { self::$log = []; } public static function save() { if (is_null(self::$driver)) { self::init(Config::get('log')); } return self::$driver->save(self::$log); } public static function write($msg, $type = 'log') { if (!is_string($msg)) { $msg = var_export($msg, true); } $log[] = ['type' => $type, 'msg' => $msg]; APP_HOOK && Hook::listen('log_write', $log); if (is_null(self::$driver)) { self::init(Config::get('log')); } return self::$driver->save($log); } public static function send($msg) { self::$alarm && self::$alarm->send($msg); } public static function __callStatic($method, $args) { if (in_array($method, self::$type)) { array_push($args, $method); return call_user_func_array('\\think\\Log::record', $args); } } } ~~~ ## 2 分析 ### 成員變量 日志類型常量 const LOG = 'log'; const ERROR = 'error'; const INFO = 'info'; const SQL = 'sql'; const NOTICE = 'notice'; const ALERT = 'alert'; 日志內容,日志類型,日志緩存驅動,日志警告驅動 protected static $log = []; protected static $type = ['log', 'error', 'info', 'sql', 'notice', 'alert']; protected static $driver = null; protected static $alarm = null; ### 成員方法 >[info] init() 日志驅動初始化 `public static function init($config = [])` > $config: 日志配置參數 * * * * * >[info] alarm() 警告驅動初始化 `public static function alarm($config = [])` > $config:日志配置參數 * * * * * >[info] getLog() 獲取日志內容 `public static function getLog()` * * * * * >[info] recode() 記錄日志信息到$log `public static function record($msg, $type = 'log')` > $msg:日志內容 > $type:日志類型 * * * * * >[info] log() 清空日志內容 `public static function clear()` * * * * * >[info] save() 保存日志內容 `public static function save()` * * * * * >[info] write() 實時保存日志內容 `public static function write($msg, $type = 'log')` > $msg:日志內容 > $type:日志類型 可回調log_write標簽行為 * * * * * >[info] send() 發送警告 `public static function send($msg)` > $msg:調試信息 * * * * * >[info] __callStatic() 靜態調用 `public static function __callStatic($method, $args)` > $method:靜態方法名稱 > ['log', 'error', 'info', 'sql', 'notice', 'alert']其中一個 > $args:日志參數 例如:Log::Log(xx) ## 3 總結 Log.php 記錄調試信息到內存, 可以使用save() write()保存到文件 還可以使用send()發送預警信息
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看