Commit 92b52cfa authored by Euan游根明's avatar Euan游根明

perf: 日志

parent bc314265
......@@ -55,7 +55,7 @@ class Nacos
}
self::info($logs);
} catch (\Exception $e) {
self::info(['msg'=>'获取配置失败'. $key.':'.$e->getMessage(),'ex'=> $e]);
self::info(['msg'=>'获取配置失败'. $key.':'.$e->getMessage(),'ex'=>$e->getTraceAsString()]);
}
}
......@@ -135,34 +135,39 @@ class Nacos
* @return mixed|string
*/
public static function getConfigRequest($url){
// 创建一个cURL资源
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Access-Type: application/json",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
if ($err){
self::info($err);
}
curl_close($curl);
$data = json_decode($response,true);
if (isset($data['status']) && $data['status'] == 403){
throw new \Exception('token过期',403);
}
if (isset($data['code']) && $data['code'] !== 0){
self::info('获取配置返回结果:'.$response);
return '';
try {
// 创建一个cURL资源
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Content-Type: application/json",
"Access-Type: application/json",
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
if ($err){
self::info($err);
}
curl_close($curl);
$data = json_decode($response,true);
if (isset($data['status']) && $data['status'] == 403){
throw new \Exception('token过期',403);
}
if (isset($data['code']) && $data['code'] !== 0){
self::info('获取配置返回结果:'.$response);
return '';
}
return $data['data'] ?? '';
} catch (\Exception $e) {
self::info(['msg'=>$e->getMessage(),'ex'=>$e->getTraceAsString()]);
}
return $data['data'] ?? '';
}
......@@ -201,7 +206,7 @@ class Nacos
$loginDataArr = json_decode($response,true);
return $loginDataArr['accessToken'] ?? '';
} catch (\Exception $e) {
self::info($e->getMessage());
self::info(['msg'=>$e->getMessage(),'ex'=>$e->getTraceAsString()]);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment