zoukankan      html  css  js  c++  java
  • ThinkPHP 日志

        

    首先需要引入:

    use ThinkLog;

    方式一: 简单

    Log::record("== xxx更新失败 ==", 'DEBUG'); 

    方式二:结合异常处理,记录异常的原因

    // 结合异常处理,记录异常的原因
    try {   // 异常处理
        if ($x === false) {
            throw new Exception(“错误原因”);
        }
    } catch (Exception $ex) {
        Log::record("== xxx更新失败 ==", 'DEBUG'); 
        Log::record($ex->getMessage(), 'DEBUG');
    }

    方式三:定位日志位置,利用PHP魔术常亮  

    Log::record(__FILE__ . "[" . __LINE__ . "L]" . " (发送短信通知" );
    
    // ……
    
    Log::record(__FILE__ . "[" . __LINE__ . "L]" . $sms_message );

    说明:

      ①:日志的结果如下:F:WWWxxxxxxApplicationPayLogicOrderLogic.class.php[214L](方式短信通知)

      ②:__FILE__  =》 当前文件的完整路径和文件名  

      ③:__LINE__  =》 当前文件的行数  

    数组的打印发送:

    // 方式1:把数组编译成Json格式,打印
            Log::record("微信服务器异步通知传来的数组:" . json_encode($data),'DEBUG');
    
    // 方式2:打印数组
    
            Log::record('微信服务器异步通知传来的数组:', 'DEBUG');
            $log = print_r($data, true);
            Log::record($log, 'DEBUG');
  • 相关阅读:
    webpack-配置
    webpack-配置
    webpack-配置
    Maximum Depth of Binary Tree
    Maximum Depth of Binary Tree
    Maximum Depth of Binary Tree
    Maximum Depth of Binary Tree
    网页中嵌入swf文件的几种方法
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
  • 原文地址:https://www.cnblogs.com/wangyuman26/p/6579572.html
Copyright © 2011-2022 走看看