日志函数

    //参数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."\r\n";
        if( \Think\Storage::has($file) ){
            $content =  $str.\Think\Storage::read($file);
        }
        return \Think\Storage::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."\r\n";
        error_log($error_content, 3, $this->log);
    }

 

posted @ 2015-09-18 11:24  chy1000  阅读(252)  评论(0编辑  收藏  举报