1.fastadmin之Log日志使用

版权声明:本文为博主原创文章,未经博主允许不得转载 https://blog.csdn.net/panzina/article/details/83375207

要开始用fastadmin做小程序的后台。怎么说,这个框架封装的很好,对于我这种新手渣渣不太友好,惆怅~

首先来谈谈日志的使用吧,如何打个log。

一.概念

1.在控制器中声明

use think\Log;

2.log的方法,一般我使用log::write(),因为它可以实时监控

3.语法

Log::write('测试日志信息,这是警告级别,并且实时写入','notice');

4.日志的级别

二,使用

啦啦啦,基础概念讲完了。来谈谈实际在fastadmin中的运用

public function index(){
		if($this->request->isAjax()){
                        //接口
			$url = "";
                        //发送请求
			$res = make_request($url);
                        //将接口返回的信息写入日志
			Log::write('index.res'.$res['result'],'info');
		}
	}

可以从这里查看日志

三.最后json_encode与json_decode

1.json_encode:对变量进行JSON编码

2.json_decode:对JSON格式的字符串进行解码,转换成PHP变量

猜你喜欢

转载自blog.csdn.net/panzina/article/details/83375207