com.github.rexsheng.springboot.faster.system.log.domain.SysLog Maven / Gradle / Ivy
The newest version!
package com.github.rexsheng.springboot.faster.system.log.domain;
import com.github.rexsheng.springboot.faster.logging.QueueLogWriter;
import com.github.rexsheng.springboot.faster.util.StringUtils;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.Optional;
public class SysLog {
private String logId;
private String className;
private String methodName;
private String methodNote;
private String requestMethod;
private String requestUrl;
private String requestIp;
private String requestParam;
private String requestHeader;
private String userAgent;
private String server;
private String module;
private Long user;
private LocalDateTime startTime;
private LocalDateTime endTime;
private Long costTime;
private Boolean error;
private String errorMsg;
public static SysLog of(QueueLogWriter.RequestLogEntity source){
SysLog target = new SysLog();
Map map=source.getLog();
Object requestId=map.get("requestId");
if(requestId==null){
return null;
}
target.setLogId(StringUtils.objectToString(requestId));
target.setClassName(StringUtils.objectToString(map.get("className")));
target.setMethodName(StringUtils.objectToString(map.get("methodName")));
target.setMethodNote(StringUtils.objectToString(map.get("logInfo")));
target.setRequestMethod(StringUtils.objectToString(map.get("requestMethod")));
target.setRequestUrl(StringUtils.objectToString(map.get("requestUrl")));
target.setRequestIp(StringUtils.objectToString(map.get("requestIp")));
target.setRequestParam(StringUtils.truncate(map.get("requestParam"),3000));
target.setRequestHeader(StringUtils.truncate(map.get("requestHeader"),1000));
target.setUserAgent(StringUtils.truncate(map.get("userAgent"),1000));
target.setServer(StringUtils.truncate(map.get("serverHost"),200));
target.setModule(StringUtils.truncate(map.get("moduleName"),200));
Optional.ofNullable(map.get("userId")).ifPresent(v->{
try {
target.setUser(Long.valueOf(StringUtils.objectToString(v)));
}
catch (NumberFormatException e){}
});
target.setStartTime((LocalDateTime) map.get("startTime"));
target.setEndTime((LocalDateTime) map.get("endTime"));
target.setCostTime((Long) map.get("costTime"));
target.setError((Boolean) map.get("error"));
target.setErrorMsg(StringUtils.truncate(map.get("errorMsg"),5000));
return target;
}
public String getLogId() {
return logId;
}
public void setLogId(String logId) {
this.logId = logId;
}
public String getClassName() {
return className;
}
public void setClassName(String className) {
this.className = className;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
public String getMethodNote() {
return methodNote;
}
public void setMethodNote(String methodNote) {
this.methodNote = methodNote;
}
public String getRequestMethod() {
return requestMethod;
}
public void setRequestMethod(String requestMethod) {
this.requestMethod = requestMethod;
}
public String getRequestUrl() {
return requestUrl;
}
public void setRequestUrl(String requestUrl) {
this.requestUrl = requestUrl;
}
public String getRequestIp() {
return requestIp;
}
public void setRequestIp(String requestIp) {
this.requestIp = requestIp;
}
public String getRequestParam() {
return requestParam;
}
public void setRequestParam(String requestParam) {
this.requestParam = requestParam;
}
public String getRequestHeader() {
return requestHeader;
}
public void setRequestHeader(String requestHeader) {
this.requestHeader = requestHeader;
}
public String getUserAgent() {
return userAgent;
}
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
public String getServer() {
return server;
}
public void setServer(String server) {
this.server = server;
}
public String getModule() {
return module;
}
public void setModule(String module) {
this.module = module;
}
public Long getUser() {
return user;
}
public void setUser(Long user) {
this.user = user;
}
public LocalDateTime getStartTime() {
return startTime;
}
public void setStartTime(LocalDateTime startTime) {
this.startTime = startTime;
}
public LocalDateTime getEndTime() {
return endTime;
}
public void setEndTime(LocalDateTime endTime) {
this.endTime = endTime;
}
public Long getCostTime() {
return costTime;
}
public void setCostTime(Long costTime) {
this.costTime = costTime;
}
public Boolean getError() {
return error;
}
public void setError(Boolean error) {
this.error = error;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy