feat: 添加 spring-boot-log starter.

This commit is contained in:
lijiahang
2023-06-30 11:16:43 +08:00
parent 2cbca21adb
commit 9b9504452f
17 changed files with 103 additions and 57 deletions

View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.orion.ops</groupId>
<artifactId>orion-ops-framework</artifactId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>orion-ops-spring-boot-starter-log</artifactId>
<name>${project.artifactId}</name>
<packaging>jar</packaging>
<description>项目日志配置包</description>
<url>https://github.com/lijiahangmax/orion-ops-pro</url>
<dependencies>
<dependency>
<groupId>com.orion.ops</groupId>
<artifactId>orion-ops-common</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<!-- doc -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View File

@@ -1,10 +1,10 @@
package com.orion.ops.framework.web.config;
package com.orion.ops.framework.log.config;
import com.orion.ops.framework.common.constant.InterceptorOrderConst;
import com.orion.ops.framework.web.core.config.LogPrinterConfig;
import com.orion.ops.framework.web.core.interceptor.LogPrinterInterceptor;
import com.orion.ops.framework.web.core.interceptor.PrettyLogPrinterInterceptor;
import com.orion.ops.framework.web.core.interceptor.RowLogPrinterInterceptor;
import com.orion.ops.framework.log.core.config.LogPrinterConfig;
import com.orion.ops.framework.log.core.interceptor.LogPrinterInterceptor;
import com.orion.ops.framework.log.core.interceptor.PrettyLogPrinterInterceptor;
import com.orion.ops.framework.log.core.interceptor.RowLogPrinterInterceptor;
import org.springframework.aop.aspectj.AspectJExpressionPointcutAdvisor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfiguration;

View File

@@ -1,6 +1,6 @@
package com.orion.ops.framework.web.core.config;
package com.orion.ops.framework.log.core.config;
import com.orion.ops.framework.web.core.utils.Utils;
import com.orion.ops.framework.log.core.utils.Utils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

View File

@@ -1,6 +1,6 @@
package com.orion.ops.framework.web.core.config;
package com.orion.ops.framework.log.core.config;
import com.orion.ops.framework.web.core.utils.Utils;
import com.orion.ops.framework.log.core.utils.Utils;
import lombok.Data;
import java.util.List;

View File

@@ -1,4 +1,4 @@
package com.orion.ops.framework.web.core.interceptor;
package com.orion.ops.framework.log.core.interceptor;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
@@ -12,8 +12,8 @@ import com.orion.lang.utils.reflect.Classes;
import com.orion.ops.framework.common.annotation.IgnoreLog;
import com.orion.ops.framework.common.constant.Const;
import com.orion.ops.framework.common.meta.TraceIdHolder;
import com.orion.ops.framework.web.core.config.LogPrinterConfig;
import com.orion.ops.framework.common.utils.Desensitizes;
import com.orion.ops.framework.log.core.config.LogPrinterConfig;
import io.swagger.v3.oas.annotations.Operation;
import org.aopalliance.intercept.MethodInvocation;

View File

@@ -1,4 +1,4 @@
package com.orion.ops.framework.web.core.interceptor;
package com.orion.ops.framework.log.core.interceptor;
import org.aopalliance.intercept.MethodInterceptor;

View File

@@ -1,9 +1,9 @@
package com.orion.ops.framework.web.core.interceptor;
package com.orion.ops.framework.log.core.interceptor;
import com.orion.lang.utils.Exceptions;
import com.orion.lang.utils.Strings;
import com.orion.lang.utils.time.Dates;
import com.orion.ops.framework.web.core.config.LogPrinterConfig;
import com.orion.ops.framework.log.core.config.LogPrinterConfig;
import com.orion.web.servlet.web.Servlets;
import lombok.extern.slf4j.Slf4j;
import org.aopalliance.intercept.MethodInvocation;

View File

@@ -1,11 +1,11 @@
package com.orion.ops.framework.web.core.interceptor;
package com.orion.ops.framework.log.core.interceptor;
import com.alibaba.fastjson.JSON;
import com.orion.lang.utils.Exceptions;
import com.orion.lang.utils.Strings;
import com.orion.lang.utils.time.Dates;
import com.orion.ops.framework.web.core.config.LogPrinterConfig;
import com.orion.ops.framework.web.core.enums.LogFieldConst;
import com.orion.ops.framework.log.core.config.LogPrinterConfig;
import com.orion.ops.framework.log.core.enums.LogFieldConst;
import com.orion.web.servlet.web.Servlets;
import lombok.extern.slf4j.Slf4j;
import org.aopalliance.intercept.MethodInvocation;

View File

@@ -1,4 +1,4 @@
package com.orion.ops.framework.web.core.utils;
package com.orion.ops.framework.log.core.utils;
import java.util.Arrays;
import java.util.List;

View File

@@ -0,0 +1,37 @@
{
"groups": [
{
"name": "logging.printer",
"type": "com.orion.ops.framework.log.core.config.LogPrinterConfig",
"sourceType": "com.orion.ops.framework.log.core.config.LogPrinterConfig"
}
],
"properties": [
{
"name": "logging.printer.mode",
"type": "com.orion.ops.framework.log.core.enums.LogPrinterMode",
"description": "日志打印模型.",
"defaultValue": "NONE"
},
{
"name": "logging.printer.expression",
"type": "java.lang.String",
"description": "aspectj 表达式."
},
{
"name": "logging.printer.headers",
"type": "java.util.List",
"description": "需要打印的 HttpHandlers."
},
{
"name": "logging.printer.field.ignore",
"type": "java.util.List",
"description": "忽略打印的字段."
},
{
"name": "logging.printer.field.desensitize",
"type": "java.util.List",
"description": "需要脱敏的字段."
}
]
}

View File

@@ -0,0 +1 @@
com.orion.ops.framework.log.config.OrionLogPrinterConfiguration

View File

@@ -61,7 +61,7 @@ public class OrionWebAutoConfiguration implements WebMvcConfigurer {
}
/**
* @return 通用返回结果处理器
* @return 公共返回值包装处理器
*/
@Bean
public WrapperResultHandler wrapperResultHandler() {

View File

@@ -5,8 +5,10 @@ import com.orion.lang.define.wrapper.HttpWrapper;
import com.orion.lang.define.wrapper.RpcWrapper;
import com.orion.ops.framework.common.annotation.IgnoreWrapper;
import com.orion.ops.framework.common.annotation.RestWrapper;
import com.orion.ops.framework.common.constant.ResponseAdviceOrderConst;
import org.jetbrains.annotations.NotNull;
import org.springframework.core.MethodParameter;
import org.springframework.core.annotation.Order;
import org.springframework.http.MediaType;
import org.springframework.http.server.ServerHttpRequest;
import org.springframework.http.server.ServerHttpResponse;
@@ -15,12 +17,13 @@ import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseBodyAdvice;
/**
* 返回值处理器
* 公共返回值包装处理器
*
* @author Jiahang Li
* @version 1.0.0
* @since 2023/6/15 17:38
*/
@Order(ResponseAdviceOrderConst.WRAPPER)
@ControllerAdvice
public class WrapperResultHandler implements ResponseBodyAdvice<Object> {

View File

@@ -1,38 +1,5 @@
{
"groups": [
{
"name": "logging.printer",
"type": "com.orion.ops.framework.web.core.config.LogPrinterConfig",
"sourceType": "com.orion.ops.framework.web.core.config.LogPrinterConfig"
}
],
"properties": [
{
"name": "logging.printer.mode",
"type": "com.orion.ops.framework.web.core.enums.LogPrinterMode",
"description": "日志打印模型.",
"defaultValue": "NONE"
},
{
"name": "logging.printer.expression",
"type": "java.lang.String",
"description": "aspectj 表达式."
},
{
"name": "logging.printer.headers",
"type": "java.util.List",
"description": "需要打印的 HttpHandlers."
},
{
"name": "logging.printer.field.ignore",
"type": "java.util.List",
"description": "忽略打印的字段."
},
{
"name": "logging.printer.field.desensitize",
"type": "java.util.List",
"description": "需要脱敏的字段."
},
{
"name": "orion.version",
"type": "java.lang.String",

View File

@@ -1,2 +1 @@
com.orion.ops.framework.web.config.OrionWebAutoConfiguration
com.orion.ops.framework.web.config.OrionLogPrinterConfiguration
com.orion.ops.framework.web.config.OrionWebAutoConfiguration