|
@@ -2,13 +2,20 @@ package cn.gygxzc.envir.core.logger;
|
|
|
|
|
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
|
import ch.qos.logback.classic.spi.ILoggingEvent;
|
|
import cn.gygxzc.envir.core.utils.GsonUtils;
|
|
import cn.gygxzc.envir.core.utils.GsonUtils;
|
|
|
|
+import cn.gygxzc.tina.cloud.jwt.session.bean.User;
|
|
|
|
+import org.slf4j.Marker;
|
|
|
|
+
|
|
|
|
+import java.io.Serializable;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Created by niantuo on 2018/11/5.
|
|
* Created by niantuo on 2018/11/5.
|
|
* 分布式日志记录
|
|
* 分布式日志记录
|
|
*/
|
|
*/
|
|
|
|
|
|
-public class LogMessage {
|
|
|
|
|
|
+public class LogMessage implements Serializable {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public static final long serialVersionUID = 1L;
|
|
|
|
|
|
private String sysName;
|
|
private String sysName;
|
|
private String threadName;
|
|
private String threadName;
|
|
@@ -21,8 +28,14 @@ public class LogMessage {
|
|
private String marker;
|
|
private String marker;
|
|
private String propertyMap;
|
|
private String propertyMap;
|
|
private Long timeStamp;
|
|
private Long timeStamp;
|
|
|
|
+ private Long userId;
|
|
|
|
+ private String account;
|
|
|
|
+
|
|
|
|
+ public LogMessage() {
|
|
|
|
|
|
- public LogMessage(ILoggingEvent event,String name) {
|
|
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public LogMessage(ILoggingEvent event, String name) {
|
|
this.sysName = name;
|
|
this.sysName = name;
|
|
this.threadName = event.getThreadName();
|
|
this.threadName = event.getThreadName();
|
|
level = event.getLevel().levelStr;
|
|
level = event.getLevel().levelStr;
|
|
@@ -31,9 +44,34 @@ public class LogMessage {
|
|
formattedMessage = event.getFormattedMessage();
|
|
formattedMessage = event.getFormattedMessage();
|
|
loggerName = event.getLoggerName();
|
|
loggerName = event.getLoggerName();
|
|
callerData = GsonUtils.toJson(event.getCallerData());
|
|
callerData = GsonUtils.toJson(event.getCallerData());
|
|
- marker = GsonUtils.toJson(event.getMarker());
|
|
|
|
propertyMap = GsonUtils.toJson(event.getMDCPropertyMap());
|
|
propertyMap = GsonUtils.toJson(event.getMDCPropertyMap());
|
|
timeStamp = event.getTimeStamp();
|
|
timeStamp = event.getTimeStamp();
|
|
|
|
+ Marker eventMarker = event.getMarker();
|
|
|
|
+ if (eventMarker != null) {
|
|
|
|
+ marker = eventMarker.toString();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setUser(User user){
|
|
|
|
+ if (user==null)return;
|
|
|
|
+ setUserId(user.getId());
|
|
|
|
+ setAccount(user.getAccount());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setUserId(Long userId) {
|
|
|
|
+ this.userId = userId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Long getUserId() {
|
|
|
|
+ return userId;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void setAccount(String account) {
|
|
|
|
+ this.account = account;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getAccount() {
|
|
|
|
+ return account;
|
|
}
|
|
}
|
|
|
|
|
|
public void setSysName(String sysName) {
|
|
public void setSysName(String sysName) {
|