1 /*
2 * Created on 21.mar.2003
3 *
4 */
5 package net.sf.panoptes.module.log4j;
6
7 import java.util.Date;
8
9 import org.apache.log4j.spi.LoggingEvent;
10
11 /***
12 * Wraps a <code>LoggingEvent</code> instance and information regarding it such as
13 * the source host and which repository it was added to.
14 *
15 * @author Dag Liodden
16 *
17 */
18 public class LoggingEventInfo implements Comparable {
19
20 private LoggerRepository repository;
21 private LoggingEvent loggingEvent;
22 private String host;
23
24 public LoggingEventInfo(LoggerRepository repository, LoggingEvent event, String sourceHost) {
25 this.loggingEvent = event;
26 this.host = sourceHost;
27 this.repository = repository;
28 }
29
30 /***
31 * @return
32 */
33 public String getHost() {
34 return host;
35 }
36
37 /***
38 * @return
39 */
40 public LoggingEvent getLoggingEvent() {
41 return loggingEvent;
42 }
43
44 public String toString() {
45 return new Date(loggingEvent.timeStamp).toString() + ":" + getHost() + ":" + getLoggingEvent().getLocationInformation().getClassName();
46 }
47 /* (non-Javadoc)
48 * @see java.lang.Comparable#compareTo(java.lang.Object)
49 */
50 public int compareTo(Object o) {
51 if (!(o instanceof LoggingEventInfo)) throw new IllegalArgumentException("Can only compare to LoggingEventInfos");
52 LoggingEventInfo e = (LoggingEventInfo) o;
53 return toString().compareTo(e.toString());
54 }
55
56 /***
57 * @return
58 */
59 public LoggerRepository getRepository() {
60 return repository;
61 }
62
63 }
This page was automatically generated by Maven