Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nacos-config
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Euan游根明
nacos-config
Commits
92b52cfa
Commit
92b52cfa
authored
Dec 04, 2023
by
Euan游根明
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
perf: 日志
parent
bc314265
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
30 deletions
+35
-30
Nacos.php
src/Nacos/Nacos.php
+35
-30
No files found.
src/Nacos/Nacos.php
View file @
92b52cfa
...
@@ -55,7 +55,7 @@ class Nacos
...
@@ -55,7 +55,7 @@ class Nacos
}
}
self
::
info
(
$logs
);
self
::
info
(
$logs
);
}
catch
(
\Exception
$e
)
{
}
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
...
@@ -135,34 +135,39 @@ class Nacos
* @return mixed|string
* @return mixed|string
*/
*/
public
static
function
getConfigRequest
(
$url
){
public
static
function
getConfigRequest
(
$url
){
// 创建一个cURL资源
try
{
$curl
=
curl_init
();
// 创建一个cURL资源
curl_setopt_array
(
$curl
,
array
(
$curl
=
curl_init
();
CURLOPT_URL
=>
$url
,
curl_setopt_array
(
$curl
,
array
(
CURLOPT_RETURNTRANSFER
=>
true
,
CURLOPT_URL
=>
$url
,
CURLOPT_MAXREDIRS
=>
10
,
CURLOPT_RETURNTRANSFER
=>
true
,
CURLOPT_TIMEOUT
=>
30
,
CURLOPT_MAXREDIRS
=>
10
,
CURLOPT_HTTP_VERSION
=>
CURL_HTTP_VERSION_1_1
,
CURLOPT_TIMEOUT
=>
30
,
CURLOPT_CUSTOMREQUEST
=>
"GET"
,
CURLOPT_HTTP_VERSION
=>
CURL_HTTP_VERSION_1_1
,
CURLOPT_HTTPHEADER
=>
array
(
CURLOPT_CUSTOMREQUEST
=>
"GET"
,
"Content-Type: application/json"
,
CURLOPT_HTTPHEADER
=>
array
(
"Access-Type: application/json"
,
"Content-Type: application/json"
,
"cache-control: no-cache"
"Access-Type: application/json"
,
),
"cache-control: no-cache"
));
),
$response
=
curl_exec
(
$curl
);
));
$err
=
curl_error
(
$curl
);
$response
=
curl_exec
(
$curl
);
if
(
$err
){
$err
=
curl_error
(
$curl
);
self
::
info
(
$err
);
if
(
$err
){
}
self
::
info
(
$err
);
curl_close
(
$curl
);
}
$data
=
json_decode
(
$response
,
true
);
curl_close
(
$curl
);
if
(
isset
(
$data
[
'status'
])
&&
$data
[
'status'
]
==
403
){
$data
=
json_decode
(
$response
,
true
);
throw
new
\Exception
(
'token过期'
,
403
);
if
(
isset
(
$data
[
'status'
])
&&
$data
[
'status'
]
==
403
){
}
throw
new
\Exception
(
'token过期'
,
403
);
if
(
isset
(
$data
[
'code'
])
&&
$data
[
'code'
]
!==
0
){
}
self
::
info
(
'获取配置返回结果:'
.
$response
);
if
(
isset
(
$data
[
'code'
])
&&
$data
[
'code'
]
!==
0
){
return
''
;
self
::
info
(
'获取配置返回结果:'
.
$response
);
return
''
;
}
return
$data
[
'data'
]
??
''
;
}
catch
(
\Exception
$e
)
{
self
::
info
([
'msg'
=>
$e
->
getMessage
(),
'ex'
=>
$e
->
getTraceAsString
()]);
}
}
return
$data
[
'data'
]
??
''
;
return
$data
[
'data'
]
??
''
;
}
}
...
@@ -201,7 +206,7 @@ class Nacos
...
@@ -201,7 +206,7 @@ class Nacos
$loginDataArr
=
json_decode
(
$response
,
true
);
$loginDataArr
=
json_decode
(
$response
,
true
);
return
$loginDataArr
[
'accessToken'
]
??
''
;
return
$loginDataArr
[
'accessToken'
]
??
''
;
}
catch
(
\Exception
$e
)
{
}
catch
(
\Exception
$e
)
{
self
::
info
(
$e
->
getMessage
()
);
self
::
info
(
[
'msg'
=>
$e
->
getMessage
(),
'ex'
=>
$e
->
getTraceAsString
()]
);
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment