1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package net.sf.jour.log4j.ext;
22
23 import net.sf.jour.rt.agent.ProfilerEvent;
24
25 import org.apache.log4j.Category;
26 import org.apache.log4j.Priority;
27 import org.apache.log4j.spi.LocationInfo;
28 import org.apache.log4j.spi.LoggingEvent;
29 /***
30 * Convers Jour Event to printable log4j events.
31 *
32 * Created on 06.12.2004
33 * Contributing Author(s):
34 *
35 * Misha Lifschitz <mishalifschitz at users.sourceforge.net> (Inital implementation)
36 * Vlad Skarzhevskyy <vlads at users.sourceforge.net> (Inital implementation)
37 *
38 * @author vlads
39 * @version $Revision: 1.1 $ ($Author: vlads $) $Date: 2004/12/07 09:05:03 $
40 */
41 public class LoggingProfilerEvent extends LoggingEvent {
42
43 private ProfilerEvent wrapedProfilerEvent;
44
45 private transient LocationInfo locationInfo;
46
47 public LoggingProfilerEvent(String fqnOfCategoryClass, Category logger,
48 Priority level, ProfilerEvent profilerEvent) {
49 super(fqnOfCategoryClass, logger,
50 profilerEvent.getTimestampLong(),
51 level, profilerEvent.getType(), profilerEvent.getThrowable());
52 wrapedProfilerEvent = profilerEvent;
53 }
54
55
56
57
58
59 public String getLoggerName() {
60 return wrapedProfilerEvent.getClassName();
61 }
62
63
64 public String getThreadName() {
65 return wrapedProfilerEvent.getThreadName();
66 }
67
68 public class ExtLocationInfo extends LocationInfo {
69
70 public ExtLocationInfo() {
71 super(null, null);
72 }
73
74 public final static String NA = "?";
75
76 /***
77 * @return Returns the className.
78 */
79 public String getClassName() {
80 return wrapedProfilerEvent.getClassName();
81 }
82 /***
83 * @return Returns the fileName.
84 */
85 public String getFileName() {
86 return NA;
87 }
88 /***
89 * @return Returns the lineNumber.
90 */
91 public String getLineNumber() {
92 return NA;
93 }
94 /***
95 * @return Returns the methodName.
96 */
97 public String getMethodName() {
98 return wrapedProfilerEvent.getMethodName();
99 }
100 }
101
102 public LocationInfo getLocationInformation() {
103 if (locationInfo == null) {
104 locationInfo = new ExtLocationInfo();
105 }
106 return locationInfo;
107 }
108
109 }