01: package com.jamonapi.log4j;
02:
03: import org.apache.log4j.spi.LoggingEvent;
04: import com.jamonapi.*;
05:
06: /**
07: * MonKey used to put log4j records into jamon hashmap. It is the same as
08: * MonKeyImp except it also carries with it a log4j LoggingEvent. This is not
09: * used as part of the key, but is used to display log4j info in any
10: * BufferListeners this object has. To take maximum advantage of the data in the
11: * LoggingEvent of this key use a Log4jBufferListener for log4j JAMon monitors.
12: * A regular FIFO buffer can also be used, however all info in the LoggingEvent
13: * won't be used in this case.
14: *
15: * @author steve souza
16: *
17: */
18: public class Log4jMonKey extends MonKeyImp {
19:
20: /** Constructor for building jamon key for log4j */
21: public Log4jMonKey(String summaryLabel, String detailLabel,
22: String units, LoggingEvent event) {
23: super (summaryLabel, detailLabel, units);
24: setParam(event);
25: }
26:
27: /** Return the log4j LoggingEvent object that is part of this key */
28: public LoggingEvent getLoggingEvent() {
29: return (LoggingEvent) getParam();
30: }
31:
32: /**
33: * Returns any object that has a named key. For this object 'label' and
34: * 'units', and 'LoggingEvent' are valid. It is case insenstive.
35: */
36: public Object getValue(String key) {
37: if ("LoggingEvent".equalsIgnoreCase(key))
38: return getParam();
39: else
40: return super.getValue(key);
41: }
42:
43: }
|