Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-micro
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
without authentication
meibuyu-micro
Commits
959e21a3
Commit
959e21a3
authored
Feb 22, 2022
by
Liu lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
异步协程日志加入异常
parent
a5b4e2d5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
27 deletions
+33
-27
AsyncCoroutineAspect.php
src/Aspect/AsyncCoroutineAspect.php
+17
-15
LogTraceAspect.php
src/Aspect/LogTraceAspect.php
+16
-11
LogTraceHandler.php
src/Handler/LogTrace/LogTraceHandler.php
+0
-1
No files found.
src/Aspect/AsyncCoroutineAspect.php
View file @
959e21a3
...
@@ -30,21 +30,23 @@ class AsyncCoroutineAspect extends AbstractAspect
...
@@ -30,21 +30,23 @@ class AsyncCoroutineAspect extends AbstractAspect
// $proceedingJoinPoint 为连接点,通过该类的 process() 方法调用原方法并获得结果
// $proceedingJoinPoint 为连接点,通过该类的 process() 方法调用原方法并获得结果
// 在调用前进行某些处理
// 在调用前进行某些处理
return
Coroutine
::
create
(
function
()
use
(
$proceedingJoinPoint
){
return
Coroutine
::
create
(
function
()
use
(
$proceedingJoinPoint
){
try
{
LogTraceHandler
::
recordProcess
(
LogTraceHandler
::
recordProcess
(
'投递到子协程任务,id:'
.
Coroutine
::
id
()
'投递到子协程任务,id:'
.
Coroutine
::
id
()
.
' ,类:'
.
$proceedingJoinPoint
->
className
.
' ,类:'
.
$proceedingJoinPoint
->
className
.
' ,方法:'
.
$proceedingJoinPoint
->
methodName
.
' ,方法:'
.
$proceedingJoinPoint
->
methodName
.
' ,参数:'
.
json_encode
(
$proceedingJoinPoint
->
getArguments
())
.
' ,参数:'
.
json_encode
(
$proceedingJoinPoint
->
getArguments
())
,
,
true
true
);
);
$result
=
$proceedingJoinPoint
->
process
();
$result
=
$proceedingJoinPoint
->
process
();
LogTraceHandler
::
recordProcess
(
LogTraceHandler
::
recordProcess
(
'子协程任务id:'
.
Coroutine
::
id
()
.
'已完成,执行结果:'
.
'子协程任务id:'
.
Coroutine
::
id
()
.
'已完成,执行结果:'
.
json_encode
(
$result
),
true
json_encode
(
$result
),
true
);
);
}
catch
(
\Throwable
$exception
){
LogTraceHandler
::
recordProcess
(
$exception
,
true
);
}
});
});
...
...
src/Aspect/LogTraceAspect.php
View file @
959e21a3
...
@@ -26,18 +26,23 @@ class LogTraceAspect extends AbstractAspect
...
@@ -26,18 +26,23 @@ class LogTraceAspect extends AbstractAspect
public
function
process
(
ProceedingJoinPoint
$proceedingJoinPoint
)
public
function
process
(
ProceedingJoinPoint
$proceedingJoinPoint
)
{
{
try
{
$originParams
=
[
'called_params'
=>
$proceedingJoinPoint
->
getArguments
(),
'http_params'
=>
make
(
RequestInterface
::
class
)
->
all
()
];
LogTraceHandler
::
createLogTrace
(
$proceedingJoinPoint
->
className
.
'@'
.
$proceedingJoinPoint
->
methodName
,
$originParams
);
$result
=
$proceedingJoinPoint
->
process
();
LogTraceHandler
::
recordProcess
(
'返回结果:'
.
json_encode
(
$result
));
$originParams
=
[
return
$result
;
'called_params'
=>
$proceedingJoinPoint
->
getArguments
(),
}
catch
(
\Throwable
$exception
){
'http_params'
=>
make
(
RequestInterface
::
class
)
->
all
()
LogTraceHandler
::
recordProcess
(
$exception
);
];
throw
$exception
;
//保持异常抛出
LogTraceHandler
::
createLogTrace
(
}
$proceedingJoinPoint
->
className
.
'@'
.
$proceedingJoinPoint
->
methodName
,
$originParams
);
$result
=
$proceedingJoinPoint
->
process
();
LogTraceHandler
::
recordProcess
(
'返回结果:'
.
json_encode
(
$result
));
return
$result
;
}
}
}
}
\ No newline at end of file
src/Handler/LogTrace/LogTraceHandler.php
View file @
959e21a3
...
@@ -76,7 +76,6 @@ class LogTraceHandler
...
@@ -76,7 +76,6 @@ class LogTraceHandler
/**
/**
* 程序执行完成标记结束
* 程序执行完成标记结束
* @throws \Exception
*/
*/
public
static
function
markComplete
()
public
static
function
markComplete
()
{
{
...
...
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