LogUtils.php
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace App\Utils;
use App\Enums\Common\Common;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
class LogUtils
{
/**
* ERROR层级日志
* @param $title
* @param $params
* @param $response
* @return void
*/
public static function error($title, $params = [], $response = [])
{
$route=Route::current();
$side=$route->action['prefix']??Common::A;
$params = is_array($params) ? json_encode($params, JSON_UNESCAPED_UNICODE) : $params;
$response = is_array($response) || is_object($response) ? json_encode($response, JSON_UNESCAPED_UNICODE) : $response;
Log::channel($side.'side')->error("$title::请求参数:$params--------响应:$response");
}
/**
* INFO层级日志
* @param $title
* @param $params
* @param $response
* @return void
*/
public static function info($title, $params = [], $response = [])
{
$route=Route::current();
$side=$route->action['prefix']??Common::A;
$params = is_array($params) ? json_encode($params, JSON_UNESCAPED_UNICODE) : $params;
$response = is_array($response) || is_object($response) ? json_encode($response, JSON_UNESCAPED_UNICODE) : $response;
Log::channel($side.'side')->info("$title::请求参数:$params--------响应:$response");
}
}