重新组织包结构
This commit is contained in:
parent
688eb26c1e
commit
ed6a9a5d78
@ -1,4 +1,4 @@
|
|||||||
package cn.zhangdeman.filter;
|
package cn.zhangdeman.consts;
|
||||||
|
|
||||||
// http 一些枚举key
|
// http 一些枚举key
|
||||||
public class HttpField {
|
public class HttpField {
|
@ -1,4 +1,4 @@
|
|||||||
package cn.zhangdeman.filter;
|
package cn.zhangdeman.consts;
|
||||||
|
|
||||||
// 日志相关数据的枚举值
|
// 日志相关数据的枚举值
|
||||||
public class LogField {
|
public class LogField {
|
@ -1,4 +1,4 @@
|
|||||||
package cn.zhangdeman.filter;
|
package cn.zhangdeman.consts;
|
||||||
|
|
||||||
// 记录的各种字段枚举值
|
// 记录的各种字段枚举值
|
||||||
public class RecordField {
|
public class RecordField {
|
||||||
@ -34,4 +34,7 @@ public class RecordField {
|
|||||||
public static final String RESPONSE_HTTP_CODE = "http_code"; // 苍蝇状态码,默认200
|
public static final String RESPONSE_HTTP_CODE = "http_code"; // 苍蝇状态码,默认200
|
||||||
public static final String RESPONSE_HEADER = "header"; // 响应header
|
public static final String RESPONSE_HEADER = "header"; // 响应header
|
||||||
public static final String RESPONSE_COOKIE = "cookie"; // 响应header
|
public static final String RESPONSE_COOKIE = "cookie"; // 响应header
|
||||||
|
|
||||||
|
|
||||||
|
public static final String LOGGER_TYPE = "log_type"; // 日志类型
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package cn.zhangdeman.filter;
|
package cn.zhangdeman.context;
|
||||||
|
|
||||||
|
import cn.zhangdeman.consts.RecordField;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
@ -1,5 +1,6 @@
|
|||||||
package cn.zhangdeman.filter;
|
package cn.zhangdeman.context;
|
||||||
|
|
||||||
|
import cn.zhangdeman.consts.RecordField;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
@ -15,6 +16,12 @@ import java.util.Map;
|
|||||||
@Setter
|
@Setter
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true) // 忽略未知属性字段
|
@JsonIgnoreProperties(ignoreUnknown = true) // 忽略未知属性字段
|
||||||
public class Response {
|
public class Response {
|
||||||
|
@JsonProperty(RecordField.REQUEST_ID)
|
||||||
|
private String requestId; // 本次请求request id
|
||||||
|
@JsonProperty(RecordField.TRACE_ID)
|
||||||
|
private String traceId; // 全局trace id
|
||||||
|
@JsonProperty(RecordField.COST)
|
||||||
|
private Long cost; // 请求耗时
|
||||||
@JsonProperty(RecordField.RESPONSE_CODE)
|
@JsonProperty(RecordField.RESPONSE_CODE)
|
||||||
private String code; // 响应业务状态码
|
private String code; // 响应业务状态码
|
||||||
@JsonProperty(RecordField.RESPONSE_MESSAGE)
|
@JsonProperty(RecordField.RESPONSE_MESSAGE)
|
@ -1,5 +1,6 @@
|
|||||||
package cn.zhangdeman.filter;
|
package cn.zhangdeman.context;
|
||||||
|
|
||||||
|
import cn.zhangdeman.consts.RecordField;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
@ -1,7 +0,0 @@
|
|||||||
package cn.zhangdeman.filter;
|
|
||||||
|
|
||||||
|
|
||||||
public class Main {
|
|
||||||
public static void main(String[] args) {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,10 @@
|
|||||||
package cn.zhangdeman.filter;
|
package cn.zhangdeman.filter;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.zhangdeman.consts.RecordField;
|
||||||
|
import cn.zhangdeman.context.Request;
|
||||||
|
import cn.zhangdeman.context.Response;
|
||||||
|
import cn.zhangdeman.context.RuntimeContext;
|
||||||
import jakarta.servlet.FilterChain;
|
import jakarta.servlet.FilterChain;
|
||||||
import jakarta.servlet.FilterConfig;
|
import jakarta.servlet.FilterConfig;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
40
src/main/java/cn/zhangdeman/logger/LogData.java
Normal file
40
src/main/java/cn/zhangdeman/logger/LogData.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package cn.zhangdeman.logger;
|
||||||
|
|
||||||
|
import cn.zhangdeman.consts.RecordField;
|
||||||
|
import cn.zhangdeman.context.Request;
|
||||||
|
import cn.zhangdeman.context.Response;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
// 日志数据结构
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true) // 忽略未知属性字段
|
||||||
|
public class LogData {
|
||||||
|
@JsonProperty(RecordField.LOGGER_TYPE)
|
||||||
|
private String LogType;
|
||||||
|
@JsonProperty(RecordField.REQUEST_ID)
|
||||||
|
private String requestId; // 本次请求request id
|
||||||
|
@JsonProperty(RecordField.COST)
|
||||||
|
private Long cost; // 请求耗时
|
||||||
|
@JsonProperty(RecordField.SERVER_IP)
|
||||||
|
private String serverIp; // 服务器Ip
|
||||||
|
@JsonProperty(RecordField.SERVER_HOSTNAME)
|
||||||
|
private String serverHostname; // 服务器hostname
|
||||||
|
@JsonProperty(RecordField.FINISH_TIMESTAMP)
|
||||||
|
private Long finishTimeStamp; // 完成请求时间
|
||||||
|
@JsonProperty(RecordField.TRACE_ID)
|
||||||
|
private String traceId; // 全局trace id
|
||||||
|
@JsonProperty(RecordField.START_TIMESTAMP)
|
||||||
|
private Long startTimeStamp; // 开始请求时间
|
||||||
|
@JsonProperty(RecordField.CONTEXT_DATA)
|
||||||
|
private Map<String, Object> logData; // 本条日志的上下文信息
|
||||||
|
@JsonProperty(RecordField.REQUEST_INFO)
|
||||||
|
private Request requestInfo;// 请求信息
|
||||||
|
@JsonProperty(RecordField.RESPONSE_INFO)
|
||||||
|
private Response responseInfo; // 响应信息
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user