KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > oddjob > logging > LogEvent


1 /*
2  * (c) Rob Gordon 2005
3  */

4 package org.oddjob.logging;
5
6 import java.io.Serializable JavaDoc;
7
8 /**
9  * A LogEvent is archived in a LogArchiver. These LogEvents are Serialized so
10  * they may be sent across the network.
11  * <p>
12  * The log message should already be formatted.
13  * <p>
14  * The sequence number allows a local LogArchive to synchronize with with
15  * a remote LogArchive.
16  */

17 public class LogEvent implements Serializable JavaDoc {
18     
19     private final long number;
20     private final LogLevel level;
21     private final String JavaDoc logger;
22     private final String JavaDoc message;
23     
24     /**
25      * Construct a new LogEvent.
26      *
27      * @param logger The logger (or archive). Must not be null.
28      * @param number The sequence number for this event.
29      * @param level The LogLevel. Must not be null.
30      * @param message The formatted message. Must not be null.
31      */

32     public LogEvent(String JavaDoc logger,
33             long number, LogLevel level,
34             String JavaDoc message) {
35         if (logger == null) {
36             throw new NullPointerException JavaDoc("Logger can not be null!");
37         }
38         if (number < 0) {
39             throw new IllegalArgumentException JavaDoc("Sequence Number must be positive!");
40         }
41         if (level == null) {
42             throw new NullPointerException JavaDoc("Log Level can not be null!");
43         }
44         if (message == null) {
45             throw new NullPointerException JavaDoc("Message can not be null!");
46         }
47         
48         this.number = number;
49         this.level = level;
50         this.logger = logger;
51         this.message = message;
52     }
53     /**
54      * @return Returns the level.
55      */

56     public LogLevel getLevel() {
57         return level;
58     }
59     /**
60      * @return Returns the logger.
61      */

62     public String JavaDoc getLogger() {
63         return logger;
64     }
65     /**
66      * @return Returns the message.
67      */

68     public String JavaDoc getMessage() {
69         return message;
70     }
71     /**
72      * @return Returns the number.
73      */

74     public long getNumber() {
75         return number;
76     }
77 }
78
Popular Tags