@@ -24,37 +24,38 @@ public class ServerLogItem implements Serializable {
2424
2525 private String serverId ;
2626 private Long id ;
27- private String channelId ;
2827 private String level ;
2928 private Date date ;
3029 private String threadName ;
3130 private String category ;
3231 private String lineNumber ;
3332 private String message ;
3433 private String throwableInformation ;
35- private String channelName ;
36- private HashMap <String , Object > context ;
34+ private Map <String , String > attributes ;
3735
38- public ServerLogItem () {}
36+ public ServerLogItem () {
37+ this (null , null , null , null , null , null , null , null , null , new HashMap <>());
38+ }
3939
40- public ServerLogItem (Map <String , Object > properties ) {
41- if (properties != null ) {
42- this .context = new HashMap <>(properties );
43- } else {
44- this .context = new HashMap <>();
45- }
40+ public ServerLogItem (String message ) {
41+ this (null , null , null , null , null , null , null , message , null , new HashMap <>());
42+ }
4643
47- this .serverId = (String ) context .getOrDefault ("serverId" , "" );
48- this .id = (Long ) context .getOrDefault ("id" , 0L );
49- this .channelId = (String ) context .getOrDefault ("channelId" , "" );
50- this .channelName = (String ) context .getOrDefault ("channelName" , "" );
51- this .level = (String ) context .getOrDefault ("level" , "" );
52- this .date = (Date ) context .getOrDefault ("date" , Date .from (Instant .now ()));
53- this .threadName = (String ) context .getOrDefault ("threadName" , "" );
54- this .category = (String ) context .getOrDefault ("category" , "" );
55- this .lineNumber = (String ) context .getOrDefault ("lineNumber" , "" );
56- this .message = (String ) context .getOrDefault ("message" , "" );
57- this .throwableInformation = (String ) context .getOrDefault ("throwableInformation" , "" );
44+ public ServerLogItem (String serverId , Long id , String level , Date date , String threadName , String category , String lineNumber , String message , String throwableInformation ) {
45+ this (serverId , id , level , date , threadName , category , lineNumber , message , throwableInformation , new HashMap <>());
46+ }
47+
48+ public ServerLogItem (String serverId , Long id , String level , Date date , String threadName , String category , String lineNumber , String message , String throwableInformation , Map <String , String > attributes ) {
49+ this .serverId = serverId ;
50+ this .id = id ;
51+ this .level = level ;
52+ this .date = date ;
53+ this .threadName = threadName ;
54+ this .category = category ;
55+ this .lineNumber = lineNumber ;
56+ this .message = message ;
57+ this .throwableInformation = throwableInformation ;
58+ this .attributes = attributes ;
5859 }
5960
6061 public String getServerId () {
@@ -72,14 +73,6 @@ public Long getId() {
7273 public void setId (Long id ) {
7374 this .id = id ;
7475 }
75-
76- public String getChannelId () {
77- return channelId ;
78- }
79-
80- public void setChannelId (String channelId ) {
81- this .channelId = channelId ;
82- }
8376
8477 public String getLevel () {
8578 return level ;
@@ -136,21 +129,33 @@ public String getThrowableInformation() {
136129 public void setThrowableInformation (String throwableInformation ) {
137130 this .throwableInformation = throwableInformation ;
138131 }
139-
140- public String getChannelName () {
141- return channelName ;
132+
133+ public Map < String , String > getAttributes () {
134+ return attributes ;
142135 }
143-
144- public void setChannelName (String channelName ) {
145- this .channelName = channelName ;
136+
137+ public void setAttributes (Map <String , String > attributes ) {
138+ if (attributes == null ) {
139+ this .attributes = new HashMap <String , String >();
140+ } else {
141+ this .attributes = attributes ;
142+ }
146143 }
147-
148- public Map <String , Object > getContext () {
149- return context ;
144+
145+ public String getChannelId () {
146+ return this .attributes .get ("channelId" );
147+ }
148+
149+ public void setChannelId (String channelId ) {
150+ this .attributes .put ("channelId" , channelId );
150151 }
151152
152- public void setContext (Map <String , Object > context ) {
153- this .context = new HashMap <>(context );
153+ public String getChannelName () {
154+ return this .attributes .get ("channelName" );
155+ }
156+
157+ public void setChannelName (String channelName ) {
158+ this .attributes .put ("channelName" , channelName );
154159 }
155160
156161 @ Override
0 commit comments