瀏覽代碼

log打印异常,单参数去掉{}

徐玉祥 4 年之前
父節點
當前提交
bc95363987

+ 1 - 1
guns-base-support/guns-core/src/main/java/cn/stylefeng/guns/core/util/IpAddressUtil.java

@ -94,7 +94,7 @@ public class IpAddressUtil {
            //根据url获取地址
            //根据url获取地址
            resultJson = HttpUtil.get(URL, genParamMap(ip));
            resultJson = HttpUtil.get(URL, genParamMap(ip));
        } catch (Exception e) {
        } catch (Exception e) {
            log.error(">>> 根据ip定位异常! {}", e);
            log.error(">>> 根据ip定位异常:", e);
            return resultJson;
            return resultJson;
        }
        }
        if (ObjectUtil.isEmpty(resultJson)) {
        if (ObjectUtil.isEmpty(resultJson)) {

+ 13 - 13
guns-base-support/guns-system/src/main/java/cn/stylefeng/guns/sys/core/error/GlobalExceptionHandler.java

@ -83,7 +83,7 @@ public class GlobalExceptionHandler {
    @ExceptionHandler(TencentSmsException.class)
    @ExceptionHandler(TencentSmsException.class)
    @ResponseBody
    @ResponseBody
    public ErrorResponseData aliyunSmsException(TencentSmsException e) {
    public ErrorResponseData aliyunSmsException(TencentSmsException e) {
        log.error(">>> 发送短信异常: {}", e.getErrorMessage());
        log.error(">>> 发送短信异常:", e.getErrorMessage());
        return renderJson(500, e.getErrorMessage());
        return renderJson(500, e.getErrorMessage());
    }
    }
@ -96,7 +96,7 @@ public class GlobalExceptionHandler {
    @ExceptionHandler(AliyunSmsException.class)
    @ExceptionHandler(AliyunSmsException.class)
    @ResponseBody
    @ResponseBody
    public ErrorResponseData aliyunSmsException(AliyunSmsException e) {
    public ErrorResponseData aliyunSmsException(AliyunSmsException e) {
        log.error(">>> 发送短信异常: {}", e.getErrorMessage());
        log.error(">>> 发送短信异常:", e.getErrorMessage());
        return renderJson(500, e.getErrorMessage());
        return renderJson(500, e.getErrorMessage());
    }
    }
@ -109,7 +109,7 @@ public class GlobalExceptionHandler {
    @ExceptionHandler(HttpMessageNotReadableException.class)
    @ExceptionHandler(HttpMessageNotReadableException.class)
    @ResponseBody
    @ResponseBody
    public ErrorResponseData httpMessageNotReadable(HttpMessageNotReadableException e) {
    public ErrorResponseData httpMessageNotReadable(HttpMessageNotReadableException e) {
        log.error(">>> 参数格式传递异常: {}", RequestTypeExceptionEnum.REQUEST_JSON_ERROR.getMessage());
        log.error(">>> 参数格式传递异常:", RequestTypeExceptionEnum.REQUEST_JSON_ERROR.getMessage());
        return renderJson(RequestTypeExceptionEnum.REQUEST_JSON_ERROR);
        return renderJson(RequestTypeExceptionEnum.REQUEST_JSON_ERROR);
    }
    }
@ -122,7 +122,7 @@ public class GlobalExceptionHandler {
    @ExceptionHandler(HttpMediaTypeNotSupportedException.class)
    @ExceptionHandler(HttpMediaTypeNotSupportedException.class)
    @ResponseBody
    @ResponseBody
    public ErrorResponseData httpMediaTypeNotSupport(HttpMediaTypeNotSupportedException e) {
    public ErrorResponseData httpMediaTypeNotSupport(HttpMediaTypeNotSupportedException e) {
        log.error(">>> 参数格式传递异常: {}", RequestTypeExceptionEnum.REQUEST_TYPE_IS_JSON.getMessage());
        log.error(">>> 参数格式传递异常:", RequestTypeExceptionEnum.REQUEST_TYPE_IS_JSON.getMessage());
        return renderJson(RequestTypeExceptionEnum.REQUEST_TYPE_IS_JSON);
        return renderJson(RequestTypeExceptionEnum.REQUEST_TYPE_IS_JSON);
    }
    }
@ -136,11 +136,11 @@ public class GlobalExceptionHandler {
    @ResponseBody
    @ResponseBody
    public ErrorResponseData methodNotSupport(HttpServletRequest request) {
    public ErrorResponseData methodNotSupport(HttpServletRequest request) {
        if (ServletUtil.isPostMethod(request)) {
        if (ServletUtil.isPostMethod(request)) {
            log.error(">>> 请求方法异常: {}", RequestMethodExceptionEnum.REQUEST_METHOD_IS_GET.getMessage());
            log.error(">>> 请求方法异常:", RequestMethodExceptionEnum.REQUEST_METHOD_IS_GET.getMessage());
            return renderJson(RequestMethodExceptionEnum.REQUEST_METHOD_IS_GET);
            return renderJson(RequestMethodExceptionEnum.REQUEST_METHOD_IS_GET);
        }
        }
        if (ServletUtil.isGetMethod(request)) {
        if (ServletUtil.isGetMethod(request)) {
            log.error(">>> 请求方法异常: {}", RequestMethodExceptionEnum.REQUEST_METHOD_IS_POST.getMessage());
            log.error(">>> 请求方法异常:", RequestMethodExceptionEnum.REQUEST_METHOD_IS_POST.getMessage());
            return renderJson(RequestMethodExceptionEnum.REQUEST_METHOD_IS_POST);
            return renderJson(RequestMethodExceptionEnum.REQUEST_METHOD_IS_POST);
        }
        }
        return null;
        return null;
@ -156,7 +156,7 @@ public class GlobalExceptionHandler {
    @ResponseStatus(HttpStatus.NOT_FOUND)
    @ResponseStatus(HttpStatus.NOT_FOUND)
    @ResponseBody
    @ResponseBody
    public ErrorResponseData notFound(NoHandlerFoundException e) {
    public ErrorResponseData notFound(NoHandlerFoundException e) {
        log.error(">>> 资源不存在异常: {}", e);
        log.error(">>> 资源不存在异常:", e);
        return renderJson(PermissionExceptionEnum.URL_NOT_EXIST);
        return renderJson(PermissionExceptionEnum.URL_NOT_EXIST);
    }
    }
@ -170,7 +170,7 @@ public class GlobalExceptionHandler {
    @ResponseBody
    @ResponseBody
    public ErrorResponseData methodArgumentNotValidException(MethodArgumentNotValidException e) {
    public ErrorResponseData methodArgumentNotValidException(MethodArgumentNotValidException e) {
        String argNotValidMessage = getArgNotValidMessage(e.getBindingResult());
        String argNotValidMessage = getArgNotValidMessage(e.getBindingResult());
        log.error(">>> 参数校验错误异常: {}", argNotValidMessage);
        log.error(">>> 参数校验错误异常:", argNotValidMessage);
        return renderJson(ParamExceptionEnum.PARAM_ERROR.getCode(), argNotValidMessage);
        return renderJson(ParamExceptionEnum.PARAM_ERROR.getCode(), argNotValidMessage);
    }
    }
@ -184,7 +184,7 @@ public class GlobalExceptionHandler {
    @ResponseBody
    @ResponseBody
    public ErrorResponseData paramError(BindException e) {
    public ErrorResponseData paramError(BindException e) {
        String argNotValidMessage = getArgNotValidMessage(e.getBindingResult());
        String argNotValidMessage = getArgNotValidMessage(e.getBindingResult());
        log.error(">>> 参数校验错误异常: {}", argNotValidMessage);
        log.error(">>> 参数校验错误异常:", argNotValidMessage);
        return renderJson(ParamExceptionEnum.PARAM_ERROR.getCode(), argNotValidMessage);
        return renderJson(ParamExceptionEnum.PARAM_ERROR.getCode(), argNotValidMessage);
    }
    }
@ -197,7 +197,7 @@ public class GlobalExceptionHandler {
    @ExceptionHandler(AuthException.class)
    @ExceptionHandler(AuthException.class)
    @ResponseBody
    @ResponseBody
    public ErrorResponseData authFail(AuthException e) {
    public ErrorResponseData authFail(AuthException e) {
        log.error(">>> 认证异常: {}", e.getMessage());
        log.error(">>> 认证异常:", e.getMessage());
        return renderJson(e.getCode(), e.getErrorMessage());
        return renderJson(e.getCode(), e.getErrorMessage());
    }
    }
@ -210,7 +210,7 @@ public class GlobalExceptionHandler {
    @ExceptionHandler(PermissionException.class)
    @ExceptionHandler(PermissionException.class)
    @ResponseBody
    @ResponseBody
    public ErrorResponseData noPermission(PermissionException e) {
    public ErrorResponseData noPermission(PermissionException e) {
        log.error(">>> 权限异常: {}", e.getMessage());
        log.error(">>> 权限异常:", e.getMessage());
        return renderJson(e.getCode(), e.getErrorMessage());
        return renderJson(e.getCode(), e.getErrorMessage());
    }
    }
@ -223,7 +223,7 @@ public class GlobalExceptionHandler {
    @ExceptionHandler(ServiceException.class)
    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    @ResponseBody
    public ErrorResponseData businessError(ServiceException e) {
    public ErrorResponseData businessError(ServiceException e) {
        log.error(">>> 业务异常: {}", e.getMessage());
        log.error(">>> 业务异常:", e.getMessage());
        return renderJson(e.getCode(), e.getErrorMessage(), e);
        return renderJson(e.getCode(), e.getErrorMessage(), e);
    }
    }
@ -238,7 +238,7 @@ public class GlobalExceptionHandler {
    @ExceptionHandler(MyBatisSystemException.class)
    @ExceptionHandler(MyBatisSystemException.class)
    @ResponseBody
    @ResponseBody
    public ErrorResponseData persistenceException(MyBatisSystemException e) {
    public ErrorResponseData persistenceException(MyBatisSystemException e) {
        log.error(">>> mybatis操作出现异常: {}", e.getMessage());
        log.error(">>> mybatis操作出现异常:", e.getMessage());
        Throwable cause = e.getCause();
        Throwable cause = e.getCause();
        if (cause instanceof PersistenceException) {
        if (cause instanceof PersistenceException) {
            Throwable secondCause = cause.getCause();
            Throwable secondCause = cause.getCause();

+ 2 - 2
guns-base-support/guns-system/src/main/java/cn/stylefeng/guns/sys/core/filter/security/JwtAuthenticationTokenFilter.java

@ -55,7 +55,7 @@ import java.io.IOException;
@Component
@Component
public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
    private static Log log = Log.get();
    private static final Log log = Log.get();
    @Resource
    @Resource
    private AuthService authService;
    private AuthService authService;
@ -65,7 +65,7 @@ public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
        try {
        try {
            doFilter(request, response, filterChain);
            doFilter(request, response, filterChain);
        } catch (Exception e) {
        } catch (Exception e) {
            log.error(">>> 服务器运行异常: {}", e);
            log.error(">>> 服务器运行异常:", e);
            ResponseUtil.responseExceptionError(response, ServerExceptionEnum.SERVER_ERROR.getCode(),
            ResponseUtil.responseExceptionError(response, ServerExceptionEnum.SERVER_ERROR.getCode(),
                    ServerExceptionEnum.SERVER_ERROR.getMessage(), e.getStackTrace()[0].toString());
                    ServerExceptionEnum.SERVER_ERROR.getMessage(), e.getStackTrace()[0].toString());
        }
        }

+ 1 - 1
guns-base-support/guns-system/src/main/java/cn/stylefeng/guns/sys/core/listener/ConstantsInitListener.java

@ -91,7 +91,7 @@ public class ConstantsInitListener implements ApplicationListener<ApplicationCon
                entityList.forEach(sysConfig -> ConstantContext.putConstant(sysConfig.getStr("code"), sysConfig.getStr("value")));
                entityList.forEach(sysConfig -> ConstantContext.putConstant(sysConfig.getStr("code"), sysConfig.getStr("value")));
            }
            }
        } catch (SQLException | ClassNotFoundException e) {
        } catch (SQLException | ClassNotFoundException e) {
            log.error(">>> 读取数据库constants配置信息出错!", e);
            log.error(">>> 读取数据库constants配置信息出错:", e);
            throw new ServiceException(DATA_SOURCE_NOT_EXIST);
            throw new ServiceException(DATA_SOURCE_NOT_EXIST);
        } finally {
        } finally {
            DbUtil.close(conn);
            DbUtil.close(conn);

+ 4 - 4
guns-base-support/guns-system/src/main/java/cn/stylefeng/guns/sys/core/log/factory/LogTaskFactory.java

@ -64,7 +64,7 @@ public class LogTaskFactory {
                    LogFactory.createSysLoginLog(sysVisLog, account, success, failMessage);
                    LogFactory.createSysLoginLog(sysVisLog, account, success, failMessage);
                    sysVisLogService.save(sysVisLog);
                    sysVisLogService.save(sysVisLog);
                } catch (Exception e) {
                } catch (Exception e) {
                    log.error(">>> 创建登录日志异常! {}", e);
                    log.error(">>> 创建登录日志异常:", e);
                }
                }
            }
            }
        };
        };
@ -84,7 +84,7 @@ public class LogTaskFactory {
                    LogFactory.createSysExitLog(sysVisLog, account);
                    LogFactory.createSysExitLog(sysVisLog, account);
                    sysVisLogService.save(sysVisLog);
                    sysVisLogService.save(sysVisLog);
                } catch (Exception e) {
                } catch (Exception e) {
                    log.error(">>> 创建退出日志异常! {}", e);
                    log.error(">>> 创建退出日志异常:", e);
                }
                }
            }
            }
        };
        };
@ -104,7 +104,7 @@ public class LogTaskFactory {
                    LogFactory.createSysOperationLog(sysOpLog, account, businessLog, joinPoint, result);
                    LogFactory.createSysOperationLog(sysOpLog, account, businessLog, joinPoint, result);
                    sysOpLogService.save(sysOpLog);
                    sysOpLogService.save(sysOpLog);
                } catch (Exception e) {
                } catch (Exception e) {
                    log.error(">>> 创建操作日志异常! {}", e);
                    log.error(">>> 创建操作日志异常:", e);
                }
                }
            }
            }
        };
        };
@ -124,7 +124,7 @@ public class LogTaskFactory {
                    LogFactory.createSysExceptionLog(sysOpLog, account, businessLog, joinPoint, exception);
                    LogFactory.createSysExceptionLog(sysOpLog, account, businessLog, joinPoint, exception);
                    sysOpLogService.save(sysOpLog);
                    sysOpLogService.save(sysOpLog);
                } catch (Exception e) {
                } catch (Exception e) {
                    log.error(">>> 创建异常日志异常! {}", e);
                    log.error(">>> 创建异常日志异常:", e);
                }
                }
            }
            }
        };
        };

+ 6 - 1
guns-base-support/guns-system/src/main/java/cn/stylefeng/guns/sys/modular/email/enums/SysEmailExceptionEnum.java

@ -52,7 +52,12 @@ public enum SysEmailExceptionEnum implements AbstractBaseExceptionEnum {
    /**
    /**
     * 内容为空
     * 内容为空
     */
     */
    EMAIL_CONTENT_EMPTY(3, "内容为空,请检查content参数");
    EMAIL_CONTENT_EMPTY(3, "内容为空,请检查content参数"),
    /**
     * 邮件发送失败
     */
    EMAIL_SEND_ERROR(4, "邮件发送失败,请检查发送参数");
    private final Integer code;
    private final Integer code;

+ 4 - 4
guns-base-support/guns-system/src/main/java/cn/stylefeng/guns/sys/modular/file/service/impl/SysFileInfoServiceImpl.java

@ -207,7 +207,7 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
            // 返回文件字节码
            // 返回文件字节码
            fileBytes = fileOperator.getFileBytes(DEFAULT_BUCKET, sysFileInfo.getFileObjectName());
            fileBytes = fileOperator.getFileBytes(DEFAULT_BUCKET, sysFileInfo.getFileObjectName());
        } catch (Exception e) {
        } catch (Exception e) {
            log.error(">>> 获取文件流异常", e);
            log.error(">>> 获取文件流异常:", e);
            throw new ServiceException(SysFileInfoExceptionEnum.FILE_STREAM_ERROR);
            throw new ServiceException(SysFileInfoExceptionEnum.FILE_STREAM_ERROR);
        }
        }
@ -281,11 +281,11 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
                //输出
                //输出
                IoUtil.write(outputStream, true, fileBytes);
                IoUtil.write(outputStream, true, fileBytes);
            } catch (IOException e) {
            } catch (IOException e) {
                log.error(">>> 预览文件异常", e);
                log.error(">>> 预览文件异常:", e);
                throw new ServiceException(SysFileInfoExceptionEnum.PREVIEW_ERROR_NOT_SUPPORT);
                throw new ServiceException(SysFileInfoExceptionEnum.PREVIEW_ERROR_NOT_SUPPORT);
            } catch (LibreOfficeException e) {
            } catch (LibreOfficeException e) {
                log.error(">>> 初始化LibreOffice失败", e);
                log.error(">>> 初始化LibreOffice失败:", e);
                throw new ServiceException(SysFileInfoExceptionEnum.PREVIEW_ERROR_LIBREOFFICE);
                throw new ServiceException(SysFileInfoExceptionEnum.PREVIEW_ERROR_LIBREOFFICE);
            }
            }
@ -315,7 +315,7 @@ public class SysFileInfoServiceImpl extends ServiceImpl<SysFileInfoMapper, SysFi
            response.setContentType("application/octet-stream;charset=UTF-8");
            response.setContentType("application/octet-stream;charset=UTF-8");
            IoUtil.write(response.getOutputStream(), true, fileBytes);
            IoUtil.write(response.getOutputStream(), true, fileBytes);
        } catch (IOException e) {
        } catch (IOException e) {
            log.error(">>> 下载文件异常", e);
            log.error(">>> 下载文件异常:", e);
            throw new ServiceException(DOWNLOAD_FILE_ERROR);
            throw new ServiceException(DOWNLOAD_FILE_ERROR);
        }
        }
    }
    }