hotfix - 调整记录 API Log 的逻辑

This commit is contained in:
wangli 2024-06-28 09:43:12 +08:00
parent 6da057194a
commit f7779c0ab5

View File

@ -1,7 +1,6 @@
package cn.axzo.workflow.server.common.aspectj;
import cn.axzo.workflow.core.common.event.ApiLogEvent;
import cn.axzo.workflow.core.conf.SupportRefreshProperties;
import cn.axzo.workflow.server.common.annotation.EnvConfig;
import cn.axzo.workflow.server.common.annotation.ErrorReporter;
import cn.axzo.workflow.server.common.config.property.WorkflowProperties;
@ -62,20 +61,24 @@ public class ErrorReportAspect implements Ordered {
Signature signature = joinPoint.getSignature();
StopWatch watch = new StopWatch("running controller time");
watch.start(signature.toShortString());
Object result = joinPoint.proceed();
watch.stop();
log.info("StopWatch '{}': running time = {} 's", watch.getLastTaskName(), watch.getTotalTimeSeconds());
Object result = null;
try {
result = joinPoint.proceed();
} finally {
watch.stop();
log.info("StopWatch '{}': running time = {} 's", watch.getLastTaskName(), watch.getTotalTimeSeconds());
if (!signature.toShortString().contains("ExtAxApiLogServiceImpl")) {
String type = getType(joinPoint);
ApiLogEvent event = new ApiLogEvent(MDC.get(CTX_LOG_ID_MDC),
signature.toShortString(),
Objects.equals(type, "Controller") ? joinPoint.getArgs() : null,
Objects.equals(type, "Controller") ? result : null,
watch.getTotalTimeSeconds(),
type);
if (!signature.toShortString().contains("ExtAxApiLogServiceImpl")) {
String type = getType(joinPoint);
ApiLogEvent event = new ApiLogEvent(MDC.get(CTX_LOG_ID_MDC),
signature.toShortString(),
Objects.equals(type, "Controller") ? joinPoint.getArgs() : null,
Objects.equals(type, "Controller") ? result : null,
watch.getTotalTimeSeconds(),
type);
applicationEventPublisher.publishEvent(event);
applicationEventPublisher.publishEvent(event);
}
}
return result;
}