update(REQ-2516) - 解决一些异常日志的打印
This commit is contained in:
parent
a8d947f0f1
commit
08e469ce71
@ -0,0 +1,30 @@
|
|||||||
|
package cn.axzo.workflow.server.advice;
|
||||||
|
|
||||||
|
import cn.axzo.framework.autoconfigure.web.exception.RespErrorCodeMappingProperties;
|
||||||
|
import cn.axzo.framework.autoconfigure.web.exception.handler.AbstractExceptionApiResultHandler;
|
||||||
|
import cn.axzo.framework.domain.web.code.IRespCode;
|
||||||
|
import cn.axzo.framework.domain.web.code.RespCode;
|
||||||
|
import org.flowable.common.engine.api.FlowableOptimisticLockingException;
|
||||||
|
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import static cn.axzo.framework.domain.web.code.BaseCode.UNAVAILABLE_FOR_LEGAL_REASONS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 降级 FlowableOptimisticLockingException 异常,该异常在 Flowable 框架中是可以忽略的
|
||||||
|
*
|
||||||
|
* @author wangli
|
||||||
|
* @see CommandContext#logException()
|
||||||
|
* @since 2024/6/19 17:32
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class FlowableOptimisticLockingExceptionHandlerAdvice extends AbstractExceptionApiResultHandler<FlowableOptimisticLockingException> {
|
||||||
|
public FlowableOptimisticLockingExceptionHandlerAdvice(RespErrorCodeMappingProperties properties) {
|
||||||
|
super(properties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected IRespCode decode(FlowableOptimisticLockingException ex, IRespCode fallbackCode) {
|
||||||
|
return new RespCode(UNAVAILABLE_FOR_LEGAL_REASONS.getCode(), ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,8 +1,6 @@
|
|||||||
package cn.axzo.workflow.server.common.annotation;
|
package cn.axzo.workflow.server.common.annotation;
|
||||||
|
|
||||||
import cn.axzo.workflow.core.common.exception.WorkflowEngineException;
|
|
||||||
import cn.axzo.workflow.server.common.util.DingTalkUtils;
|
import cn.axzo.workflow.server.common.util.DingTalkUtils;
|
||||||
import cn.azxo.framework.common.utils.LogUtil;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import static cn.axzo.workflow.server.common.aspectj.RepeatSubmitAspect.argsArrayToString;
|
import static cn.axzo.workflow.server.common.aspectj.RepeatSubmitAspect.argsArrayToString;
|
||||||
@ -71,10 +69,11 @@ public enum ReporterType {
|
|||||||
public abstract void executeAction(String profile, String title, Boolean sendDingTalk, Object[] args, String shortString, Throwable e, Boolean downgrade);
|
public abstract void executeAction(String profile, String title, Boolean sendDingTalk, Object[] args, String shortString, Throwable e, Boolean downgrade);
|
||||||
|
|
||||||
private static void logWarn(Throwable throwable, String shortString) {
|
private static void logWarn(Throwable throwable, String shortString) {
|
||||||
if (throwable instanceof WorkflowEngineException) {
|
// 由于框架底层 AbstractExceptionApiResultHandler 默认会打印,所以此处都只是降级打印
|
||||||
|
// if (throwable instanceof WorkflowEngineException) {
|
||||||
log.warn("引擎内部正常业务异常类型,日志降级: " + throwable.getMessage(), throwable);
|
log.warn("引擎内部正常业务异常类型,日志降级: " + throwable.getMessage(), throwable);
|
||||||
} else {
|
// } else {
|
||||||
LogUtil.error(LogUtil.ErrorType.ERROR_BUSINESS, shortString, throwable.getMessage(), throwable);
|
// LogUtil.error(LogUtil.ErrorType.ERROR_BUSINESS, shortString, throwable.getMessage(), throwable);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import cn.axzo.workflow.core.common.event.ApiLogEvent;
|
|||||||
import cn.axzo.workflow.server.common.annotation.EnvConfig;
|
import cn.axzo.workflow.server.common.annotation.EnvConfig;
|
||||||
import cn.axzo.workflow.server.common.annotation.ErrorReporter;
|
import cn.axzo.workflow.server.common.annotation.ErrorReporter;
|
||||||
import cn.axzo.workflow.server.common.config.property.WorkflowProperties;
|
import cn.axzo.workflow.server.common.config.property.WorkflowProperties;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
@ -23,6 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static cn.azxo.framework.common.constatns.Constants.CTX_LOG_ID_MDC;
|
import static cn.azxo.framework.common.constatns.Constants.CTX_LOG_ID_MDC;
|
||||||
@ -47,6 +49,7 @@ public class ErrorReportAspect implements Ordered {
|
|||||||
private ApplicationEventPublisher applicationEventPublisher;
|
private ApplicationEventPublisher applicationEventPublisher;
|
||||||
@Resource
|
@Resource
|
||||||
private WorkflowProperties workflowProperties;
|
private WorkflowProperties workflowProperties;
|
||||||
|
private static List<String> methodNames = Lists.newArrayList("HealthCheckController.checkDeath()");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
@ -65,7 +68,9 @@ public class ErrorReportAspect implements Ordered {
|
|||||||
watch.start(signature.toShortString());
|
watch.start(signature.toShortString());
|
||||||
Object result = joinPoint.proceed();
|
Object result = joinPoint.proceed();
|
||||||
watch.stop();
|
watch.stop();
|
||||||
|
if (!methodNames.contains(watch.getLastTaskName())) {
|
||||||
log.info("StopWatch '{}': running time = {} 's", watch.getLastTaskName(), watch.getTotalTimeSeconds());
|
log.info("StopWatch '{}': running time = {} 's", watch.getLastTaskName(), watch.getTotalTimeSeconds());
|
||||||
|
}
|
||||||
|
|
||||||
if (!signature.toShortString().contains("ExtAxApiLogServiceImpl")) {
|
if (!signature.toShortString().contains("ExtAxApiLogServiceImpl")) {
|
||||||
String type = getType(joinPoint);
|
String type = getType(joinPoint);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user