1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.log4j.chainsaw;
18
19 import org.apache.log4j.Priority;
20 import org.apache.log4j.spi.LoggingEvent;
21
22 /***
23 * Represents the details of a logging event. It is intended to overcome the
24 * problem that a LoggingEvent cannot be constructed with purely fake data.
25 *
26 * @author <a href="mailto:oliver@puppycrawl.com">Oliver Burn</a>
27 * @version 1.0
28 */
29 class EventDetails {
30
31 /*** the time of the event **/
32 private final long mTimeStamp;
33 /*** the priority of the event **/
34 private final Priority mPriority;
35 /*** the category of the event **/
36 private final String mCategoryName;
37 /*** the NDC for the event **/
38 private final String mNDC;
39 /*** the thread for the event **/
40 private final String mThreadName;
41 /*** the msg for the event **/
42 private final String mMessage;
43 /*** the throwable details the event **/
44 private final String[] mThrowableStrRep;
45 /*** the location details for the event **/
46 private final String mLocationDetails;
47
48 /***
49 * Creates a new <code>EventDetails</code> instance.
50 * @param aTimeStamp a <code>long</code> value
51 * @param aPriority a <code>Priority</code> value
52 * @param aCategoryName a <code>String</code> value
53 * @param aNDC a <code>String</code> value
54 * @param aThreadName a <code>String</code> value
55 * @param aMessage a <code>String</code> value
56 * @param aThrowableStrRep a <code>String[]</code> value
57 * @param aLocationDetails a <code>String</code> value
58 */
59 EventDetails(long aTimeStamp,
60 Priority aPriority,
61 String aCategoryName,
62 String aNDC,
63 String aThreadName,
64 String aMessage,
65 String[] aThrowableStrRep,
66 String aLocationDetails)
67 {
68 mTimeStamp = aTimeStamp;
69 mPriority = aPriority;
70 mCategoryName = aCategoryName;
71 mNDC = aNDC;
72 mThreadName = aThreadName;
73 mMessage = aMessage;
74 mThrowableStrRep = aThrowableStrRep;
75 mLocationDetails = aLocationDetails;
76 }
77
78 /***
79 * Creates a new <code>EventDetails</code> instance.
80 *
81 * @param aEvent a <code>LoggingEvent</code> value
82 */
83 EventDetails(LoggingEvent aEvent) {
84
85 this(aEvent.timeStamp,
86 aEvent.getLevel(),
87 aEvent.getLoggerName(),
88 aEvent.getNDC(),
89 aEvent.getThreadName(),
90 aEvent.getRenderedMessage(),
91 aEvent.getThrowableStrRep(),
92 (aEvent.getLocationInformation() == null)
93 ? null : aEvent.getLocationInformation().fullInfo);
94 }
95
96 /*** @see #mTimeStamp **/
97 long getTimeStamp() {
98 return mTimeStamp;
99 }
100
101 /*** @see #mPriority **/
102 Priority getPriority() {
103 return mPriority;
104 }
105
106 /*** @see #mCategoryName **/
107 String getCategoryName() {
108 return mCategoryName;
109 }
110
111 /*** @see #mNDC **/
112 String getNDC() {
113 return mNDC;
114 }
115
116 /*** @see #mThreadName **/
117 String getThreadName() {
118 return mThreadName;
119 }
120
121 /*** @see #mMessage **/
122 String getMessage() {
123 return mMessage;
124 }
125
126 /*** @see #mLocationDetails **/
127 String getLocationDetails(){
128 return mLocationDetails;
129 }
130
131 /*** @see #mThrowableStrRep **/
132 String[] getThrowableStrRep() {
133 return mThrowableStrRep;
134 }
135 }