Commit 94b31584 authored by Liu lu's avatar Liu lu

异步协程日志加入异常

parent a119a36d
...@@ -31,19 +31,23 @@ class AsyncCoroutineAspect extends AbstractAspect ...@@ -31,19 +31,23 @@ class AsyncCoroutineAspect extends AbstractAspect
// 在调用前进行某些处理 // 在调用前进行某些处理
return Coroutine::create(function ()use($proceedingJoinPoint){ return Coroutine::create(function ()use($proceedingJoinPoint){
LogTraceHandler::recordProcess( try {
'投递到子协程任务,id:'.Coroutine::id() LogTraceHandler::recordProcess(
.' ,类:'.$proceedingJoinPoint->className '投递到子协程任务,id:'.Coroutine::id()
.' ,方法:'.$proceedingJoinPoint->methodName .' ,类:'.$proceedingJoinPoint->className
.' ,参数:'.json_encode($proceedingJoinPoint->getArguments()) .' ,方法:'.$proceedingJoinPoint->methodName
, .' ,参数:'.json_encode($proceedingJoinPoint->getArguments())
true ,
); true
$result = $proceedingJoinPoint->process(); );
LogTraceHandler::recordProcess( $result = $proceedingJoinPoint->process();
'子协程任务id:'.Coroutine::id().'已完成,执行结果:'. LogTraceHandler::recordProcess(
json_encode($result),true '子协程任务id:'.Coroutine::id().'已完成,执行结果:'.
); json_encode($result),true
);
}catch (\Throwable $exception){
LogTraceHandler::recordProcess($exception,true);
}
}); });
......
...@@ -26,17 +26,23 @@ class LogTraceAspect extends AbstractAspect ...@@ -26,17 +26,23 @@ class LogTraceAspect extends AbstractAspect
public function process(ProceedingJoinPoint $proceedingJoinPoint) public function process(ProceedingJoinPoint $proceedingJoinPoint)
{ {
$originParams = [ try {
'called_params'=>$proceedingJoinPoint->getArguments(), $originParams = [
'http_params'=>make(RequestInterface::class)->all() 'called_params'=>$proceedingJoinPoint->getArguments(),
]; 'http_params'=>make(RequestInterface::class)->all()
LogTraceHandler::createLogTrace( ];
$proceedingJoinPoint->className.'@'.$proceedingJoinPoint->methodName, LogTraceHandler::createLogTrace(
$originParams $proceedingJoinPoint->className.'@'.$proceedingJoinPoint->methodName,
); $originParams
$result = $proceedingJoinPoint->process(); );
LogTraceHandler::recordProcess('返回结果:'.json_encode($result)); $result = $proceedingJoinPoint->process();
LogTraceHandler::recordProcess('返回结果:'.json_encode($result));
return $result;
}catch (\Throwable $exception){
LogTraceHandler::recordProcess($exception);
throw $exception;
}
return $result;
} }
} }
\ No newline at end of file
...@@ -76,7 +76,6 @@ class LogTraceHandler ...@@ -76,7 +76,6 @@ class LogTraceHandler
/** /**
* 程序执行完成标记结束 * 程序执行完成标记结束
* @throws \Exception
*/ */
public static function markComplete() public static function markComplete()
{ {
......
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