【发布时间】:2021-09-22 20:04:51
【问题描述】:
我需要在这样的大项目中调用http请求后添加日志吗?
$response = Http::get('http://example.com');
Log::info(`add request and header and response`);
我想为所有 http 请求定义全局日志。
我需要像这样定义宏:
\Illuminate\Support\Facades\Http::macro('log',function(){
Log::info(`add request and header and response`);
});
并像这样调用http请求:
$response = Http::get('http://example.com')->log();
【问题讨论】: