日志函数

    //参数1:类型,参数2:code(定位),其它参数:值
    public function L()
    {
        $file = dirname(__FILE__)."/../../../Apps/".MODULE_NAME."/Log/".CONTROLLER_NAME.".txt";        
        $var_arr = func_get_args();
        $content_arr = array();
        foreach($var_arr as $k=>$value){
            if(!$k){
                $type = $value;
                continue;
            }
            if(1==$k){
                $code = $value;
                continue;
            }
            $value = json_encode($value);        
            $content_arr[] = $value;
        }
        if(!isset($type) || !isset($code)) return;
        
        $content = implode(" - ", $content_arr);
        $error_content = "【".$type."({$code})】-".date('Y-m-d H:i:s').":".$content."
";
        if( ThinkStorage::has($file) ){
            $content =  $str.ThinkStorage::read($file);
        }
        return ThinkStorage::put($file,$error_content);
    }
    private function L(){
        $var_arr = func_get_args();
        $content_arr = array();
        foreach($var_arr as $k=>$value){
            if(!$k){
                $type = $value;
                continue;
            }
            if(1==$k){
                $code = $value;
                continue;
            }
            //if(is_array($value) || is_object($value)){
                $value = json_encode($value);
            //}        
            $content_arr[] = $value;
        }
        if(!isset($type) || !isset($code)) return;
        
        $content = implode(" - ", $content_arr);
        $error_content = "【".$type."({$code})】-".date('Y-m-d H:i:s').":".$content."
";
        error_log($error_content, 3, $this->log);
    }
原文地址:https://www.cnblogs.com/chy1000/p/4818689.html