1
2
3
4
5
6 package cz.cuni.amis.pogamut.base.utils.logging;
7
8 import java.io.Serializable;
9 import java.util.logging.Level;
10 import java.util.logging.LogRecord;
11
12 import cz.cuni.amis.pogamut.base.agent.IAgentId;
13
14
15
16
17
18
19
20 public class NetworkLogEnvelope implements Serializable {
21
22
23
24
25 private static final long serialVersionUID = 4641171456863931174L;
26
27 private String category;
28 private Level level;
29 private long millis;
30 private String message;
31
32 public NetworkLogEnvelope(String cat, Level lev, long mil, String mes) {
33 category = cat;
34 level = lev;
35 millis = mil;
36 message = mes;
37 }
38
39 public NetworkLogEnvelope(String category, String level, String time, String message) {
40 this.category = category;
41 this.level = Level.parse(level);
42 this.millis = Long.valueOf(time).longValue();
43 this.message = message;
44 }
45
46 public LogRecord asLogRecord() {
47 LogRecord result = new LogRecord(getLevel(), getMessage());
48 result.setMillis(getMillis());
49 result.setLoggerName(getCategory());
50 return result;
51 }
52
53 public String getCategory() {
54 return category;
55 }
56
57 public Level getLevel() {
58 return level;
59 }
60
61 public long getMillis() {
62 return millis;
63 }
64
65 public String getMessage() {
66 return message;
67 }
68
69 @Override
70 public String toString() {
71 return "<" + category + "> [" + level.toString() + "] " + millis + " " + message;
72 }
73 }