调整日志打印参数优先级
This commit is contained in:
@@ -321,9 +321,15 @@ public class LogBus implements BaseParams {
|
||||
logBody.setStackTrace(fmtStackTrace(stackTrace, geWarn ? null : config.getIncludeStackTrace()));
|
||||
|
||||
// 是否打印日志
|
||||
if (geWarn || (Objects.nonNull(print) ? print : config.getPrint().booleanValue())) {
|
||||
if (Objects.nonNull(print)) {
|
||||
if (print) {
|
||||
printLog(logBody);
|
||||
}
|
||||
} else {
|
||||
if (geWarn || config.getPrint()) {
|
||||
printLog(logBody);
|
||||
}
|
||||
}
|
||||
// 异常日志不做忽略
|
||||
if (!geWarn) {
|
||||
// 不保存日志
|
||||
|
||||
@@ -2,6 +2,7 @@ package xtools.boot.web.base.exception;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.catalina.connector.ClientAbortException;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.web.HttpRequestMethodNotSupportedException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
@@ -147,6 +148,19 @@ public class GlobalControllerExceptionHandler implements BaseParams {
|
||||
return new Result<>(ResultType.NOT_FOUND, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 客户端提前断开连接
|
||||
*
|
||||
* @param e 客户端提前断开连接异常
|
||||
* @param request 请求
|
||||
*/
|
||||
@ExceptionHandler(ClientAbortException.class)
|
||||
public void handleClientAbortException(ClientAbortException e, HttpServletRequest request) {
|
||||
String title = "客户端提前断开连接";
|
||||
LogBus.init(LogLevel.WARN, LogBusBaseType.HTTP_RESPONSE).print(false).error(e).title(title).save();
|
||||
logException(title, e.getMessage(), request, e);
|
||||
}
|
||||
|
||||
/**
|
||||
* 认证异常
|
||||
*
|
||||
@@ -160,7 +174,6 @@ public class GlobalControllerExceptionHandler implements BaseParams {
|
||||
return new Result<>(ResultType.UNAUTHORIZED, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 公钥错误
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user