mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 22:57:17 +08:00 
			
		
		
		
	feat: 系统日志新增 traceId 链路号记录,方便查看完整日志链路
This commit is contained in:
		| @@ -33,12 +33,12 @@ import top.charles7c.continew.admin.monitor.mapper.LogMapper; | ||||
| import top.charles7c.continew.admin.monitor.model.entity.LogDO; | ||||
| import top.charles7c.continew.admin.system.service.UserService; | ||||
| import top.charles7c.continew.starter.core.constant.StringConstants; | ||||
| import top.charles7c.continew.starter.web.model.R; | ||||
| import top.charles7c.continew.starter.core.util.ExceptionUtils; | ||||
| import top.charles7c.continew.starter.log.common.dao.LogDao; | ||||
| import top.charles7c.continew.starter.log.common.model.LogRecord; | ||||
| import top.charles7c.continew.starter.log.common.model.LogRequest; | ||||
| import top.charles7c.continew.starter.log.common.model.LogResponse; | ||||
| import top.charles7c.continew.starter.web.model.R; | ||||
|  | ||||
| import java.net.URI; | ||||
| import java.time.LocalDateTime; | ||||
| @@ -86,7 +86,9 @@ public class LogDaoLocalImpl implements LogDao { | ||||
|         LogResponse logResponse = logRecord.getResponse(); | ||||
|         Integer statusCode = logResponse.getStatus(); | ||||
|         logDO.setStatusCode(statusCode); | ||||
|         logDO.setResponseHeaders(JSONUtil.toJsonStr(logResponse.getHeaders())); | ||||
|         Map<String, String> responseHeaders = logResponse.getHeaders(); | ||||
|         logDO.setResponseHeaders(JSONUtil.toJsonStr(responseHeaders)); | ||||
|         logDO.setTraceId(responseHeaders.get(SysConstants.TRACE_ID)); | ||||
|         String responseBody = logResponse.getBody(); | ||||
|         logDO.setResponseBody(responseBody); | ||||
|         // 状态 | ||||
|   | ||||
| @@ -16,17 +16,15 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.monitor.model.entity; | ||||
|  | ||||
| import com.baomidou.mybatisplus.annotation.TableId; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import lombok.Data; | ||||
| import top.charles7c.continew.admin.monitor.enums.LogStatusEnum; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import com.baomidou.mybatisplus.annotation.TableId; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
|  | ||||
| import top.charles7c.continew.admin.monitor.enums.LogStatusEnum; | ||||
|  | ||||
| /** | ||||
|  * 系统日志实体 | ||||
|  * | ||||
| @@ -46,6 +44,11 @@ public class LogDO implements Serializable { | ||||
|     @TableId | ||||
|     private Long id; | ||||
|  | ||||
|     /** | ||||
|      * 链路 ID | ||||
|      */ | ||||
|     private String traceId; | ||||
|  | ||||
|     /** | ||||
|      * 日志描述 | ||||
|      */ | ||||
|   | ||||
| @@ -16,22 +16,18 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.monitor.model.query; | ||||
|  | ||||
| import cn.hutool.core.date.DatePattern; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import top.charles7c.continew.starter.data.mybatis.plus.query.Query; | ||||
| import top.charles7c.continew.starter.data.mybatis.plus.query.QueryType; | ||||
|  | ||||
| import java.io.Serial; | ||||
| import java.io.Serializable; | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
|  | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| import cn.hutool.core.date.DatePattern; | ||||
|  | ||||
| import top.charles7c.continew.starter.data.mybatis.plus.query.Query; | ||||
| import top.charles7c.continew.starter.data.mybatis.plus.query.QueryType; | ||||
|  | ||||
| /** | ||||
|  * 系统日志查询条件 | ||||
|  * | ||||
| @@ -45,6 +41,12 @@ public class SystemLogQuery implements Serializable { | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 链路 ID | ||||
|      */ | ||||
|     @Schema(description = "链路 ID", example = "904846526308876288") | ||||
|     private String traceId; | ||||
|  | ||||
|     /** | ||||
|      * 创建时间 | ||||
|      */ | ||||
|   | ||||
| @@ -16,11 +16,10 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.monitor.model.resp; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import java.io.Serial; | ||||
|  | ||||
| /** | ||||
|  * 系统日志详情信息 | ||||
| @@ -35,6 +34,12 @@ public class SystemLogDetailResp extends LogResp { | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 链路 ID | ||||
|      */ | ||||
|     @Schema(description = "链路 ID", example = "904846526308876288") | ||||
|     private String traceId; | ||||
|  | ||||
|     /** | ||||
|      * 状态码 | ||||
|      */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user