Loading src/Aspect/LogTraceAspect.php +8 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,14 @@ class LogTraceAspect extends AbstractAspect $proceedingJoinPoint->className.'@'.$proceedingJoinPoint->methodName, $originParams ); $requestId = LogTraceHandler::getRequestId(); register_shutdown_function(function ()use($requestId) { LogTraceHandler::recordProcess( '致命异常:'.json_encode(error_get_last()), false, $requestId ); }); $result = $proceedingJoinPoint->process(); LogTraceHandler::recordProcess('返回结果:'.json_encode($result)); Loading src/Handler/LogTrace/LogTraceHandler.php +3 −3 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ class LogTraceHandler * @return string * @throws \Exception */ private static function getRequestId($isInAsyncCoroutine=false) public static function getRequestId($isInAsyncCoroutine=false) { $workId = posix_getpid(); $cid = Coroutine::id(); Loading @@ -92,7 +92,7 @@ class LogTraceHandler * 待写到Es后可以避免 * 记录当前日志(包括异常捕获) */ public static function recordProcess($track,$isInAsyncCoroutine=false) public static function recordProcess($track,$isInAsyncCoroutine=false,$requestId=0) { if (empty($track)) return; if(!Coroutine::inCoroutine()) return; Loading @@ -114,7 +114,7 @@ class LogTraceHandler $logInfo .= "\n\n"; container(LogTraceQueue::class)->addToQueue([ 'request_id'=>self::getRequestId($isInAsyncCoroutine), 'request_id'=>$requestId?:self::getRequestId($isInAsyncCoroutine), 'process_info'=>$logInfo ]); // $log = LogTrace::where('request_id', self::getRequestId())->first(); Loading Loading
src/Aspect/LogTraceAspect.php +8 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,14 @@ class LogTraceAspect extends AbstractAspect $proceedingJoinPoint->className.'@'.$proceedingJoinPoint->methodName, $originParams ); $requestId = LogTraceHandler::getRequestId(); register_shutdown_function(function ()use($requestId) { LogTraceHandler::recordProcess( '致命异常:'.json_encode(error_get_last()), false, $requestId ); }); $result = $proceedingJoinPoint->process(); LogTraceHandler::recordProcess('返回结果:'.json_encode($result)); Loading
src/Handler/LogTrace/LogTraceHandler.php +3 −3 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ class LogTraceHandler * @return string * @throws \Exception */ private static function getRequestId($isInAsyncCoroutine=false) public static function getRequestId($isInAsyncCoroutine=false) { $workId = posix_getpid(); $cid = Coroutine::id(); Loading @@ -92,7 +92,7 @@ class LogTraceHandler * 待写到Es后可以避免 * 记录当前日志(包括异常捕获) */ public static function recordProcess($track,$isInAsyncCoroutine=false) public static function recordProcess($track,$isInAsyncCoroutine=false,$requestId=0) { if (empty($track)) return; if(!Coroutine::inCoroutine()) return; Loading @@ -114,7 +114,7 @@ class LogTraceHandler $logInfo .= "\n\n"; container(LogTraceQueue::class)->addToQueue([ 'request_id'=>self::getRequestId($isInAsyncCoroutine), 'request_id'=>$requestId?:self::getRequestId($isInAsyncCoroutine), 'process_info'=>$logInfo ]); // $log = LogTrace::where('request_id', self::getRequestId())->first(); Loading