|
ABLE 2.0.0 07/02/2003 10:25:01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.able.AbleTraceLogger
The AbleTraceLogger class records messages and traces programs. It wrapppers functions from the com.ibm.logging package to minimize the dependancy.
The log and trace design follows the pattern established by JLog available from IBM alphaWorks. This includes:
Able.MessageLog
, a global logger used to display translatable output to an end user.Able.TraceLog
, a global logger used to display program trace output to a developer.Able
class.Able
start, stop, and change the levels of the two
provided handlers for console and file output.Able.TraceLog
.
The two global loggers and any bean using bean level logging can be
managed via static methods in the Able
class. Static methods
in this class are intended for use by those creating custom handlers
or custom loggers.
The following code snippets have been extracted from
com.ibm.able.examples.AbleTraceLogDemo
.
AbleDefaultAgent agent = new AbleDefaultAgent("Agent"); Able.setTraceConsoleHandlerLevel(Able.TRC_HIGH); //starts trace console handler thread agent.init(); // call something, at trace high, console output appears // send text and exception data on the fly agent.getTraceLogger().text(Able.TRC_MEDIUM,"Medium trace also appears at High"); Able.TraceLog.exception(Able.TRC_LOW,"com.ibm.able.examples.AbleTraceLogDemo","main",new Exception("Oops!")); Able.setTraceConsoleHandlerLevel(Able.TRC_LOW); // change the level, thread running agent.init(); // no trace output from init at low level Able.setTraceConsoleHandlerLevel(Able.TRC_NONE); // end the console handler thread // or Able.stopTraceLogging(); // end all handlers
If your application provides an instance of com.ibm.logging.Logger, you may substitute your logger for the loggers used by Able. The steps required to replace the global MessageLogger are:
Able.stopMessageLogging();
Able.MessageLogger = new AbleTraceLogger(myLogger);
for a list of trace and message types used by Able,
as well as static methods used to manipulate the static trace and message loggers.
,
Logger
, Serialized FormField Summary | |
---|---|
protected com.ibm.logging.Logger |
logger
|
static java.lang.String |
MESSAGE_CONSOLE_HANDLER
A constant used as a name to add and remove a message console handler. |
static java.lang.String |
MESSAGE_FILE_HANDLER
A constant used as a name to add and remove a message file handler. |
static java.lang.String |
MESSAGE_JTEXTAREA_HANDLER
A constant used as a name to add and remove a message textarea handler. |
static java.util.Vector |
MessageLogSeverityLabelsVector
A Vector of descriptions of each MessageLogSeverityValuesVector . |
static java.util.Vector |
MessageLogSeverityValuesVector
A Vector of message severities consisting of: Able.MSG_NONE
Able.MSG_INFO
Able.MSG_WARNING
Able.MSG_ERROR
|
static java.lang.String |
TRACE_BEAN_CONSOLE_HANDLER
A constant used as a name to add and remove a local bean trace console handler. |
static java.lang.String |
TRACE_BEAN_FILE_HANDLER
A constant used as a name to add and remove a local bean trace file handler. |
static java.lang.String |
TRACE_BEAN_JTEXTAREA_HANDLER
A constant used as a name to add and remove a local bean trace textarea handler. |
static java.lang.String |
TRACE_CONSOLE_HANDLER
A constant used as a name to add and remove a trace console handler. |
static java.lang.String |
TRACE_FILE_HANDLER
A constant used as a name to add and remove a trace file handler. |
static java.lang.String |
TRACE_JTEXTAREA_HANDLER
A constant used as a name to add and remove a trace textarea handler. |
static java.util.Vector |
TraceLogLevelLabelsVector
A Vector of descriptions of each TraceLogLevelValuesVector . |
static java.util.Vector |
TraceLogLevelValuesVector
A Vector of trace levels consisting of: Able.TRC_NONE
Able.TRC_LOW
Able.TRC_MEDIUM
Able.TRC_HIGH
|
Fields inherited from interface com.ibm.able.AbleLogger |
---|
MSG_ERROR, MSG_INFO, MSG_NONE, MSG_UNSPECIFIED, MSG_WARNING, serialVersionUID, TRC_HIGH, TRC_HIGH_INFER, TRC_HIGH_PARSE, TRC_HIGH_RLST, TRC_LOW, TRC_LOW_INFER, TRC_LOW_PARSE, TRC_LOW_RLST, TRC_MEDIUM, TRC_MEDIUM_INFER, TRC_MEDIUM_PARSE, TRC_MEDIUM_RLST, TRC_NONE |
Fields inherited from interface com.ibm.logging.IRecordType |
---|
TYPE_ALL, TYPE_API, TYPE_CALLBACK, TYPE_DEBUG_MAX, TYPE_DEBUG_MID, TYPE_DEBUG_MIN, TYPE_DEFAULT_MESSAGE, TYPE_DEFAULT_TRACE, TYPE_ENTRY, TYPE_ENTRY_EXIT, TYPE_ERR, TYPE_ERROR, TYPE_ERROR_EXC, TYPE_EXIT, TYPE_FATAL, TYPE_INFO, TYPE_INFORMATION, TYPE_LEVEL1, TYPE_LEVEL2, TYPE_LEVEL3, TYPE_MISC_DATA, TYPE_NONE, TYPE_OBJ_CREATE, TYPE_OBJ_DELETE, TYPE_PERF, TYPE_PRIVATE, TYPE_PUBLIC, TYPE_STATIC, TYPE_SVC, TYPE_WARN, TYPE_WARNING |
Constructor Summary | |
---|---|
AbleTraceLogger(com.ibm.logging.Logger theLogger)
Construct a Logger from an existing com.ibm.logging.Logger. |
|
AbleTraceLogger(java.lang.String theName,
java.lang.String theDescription)
Construct a Trace Logger of the specified name and description. |
Method Summary | |
---|---|
static java.lang.Object |
addConsoleHandler(AbleLogger theLogger,
java.lang.String handlerName,
long level)
Add a ConsoleHandler to a logger. |
static java.lang.Object |
addFileHandler(AbleLogger theLogger,
java.lang.String handlerName,
long level,
java.lang.String filename)
Add a FileHandler to a logger. |
static java.lang.Object |
addHandler(AbleLogger theLogger,
java.lang.Object theHandler,
long level)
Add a handler to a specific logger with a filter for the specified level. |
void |
addHandler(java.lang.Object theHandler,
long level)
Add a handler to this logger. |
static java.lang.String |
Copyright()
Determine the copyright of this class. |
void |
entry(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod)
Log a method entry trace statement without parameters. |
void |
entry(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod,
java.lang.Object parm)
Log a method entry trace statement with one parameter. |
void |
entry(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod,
java.lang.Object[] parms)
Log a method entry trace statement with multiple parameters. |
void |
exception(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod,
java.lang.Throwable throwable)
Log an exception. |
void |
exit(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod)
Log a method exit trace statement with no result. |
void |
exit(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod,
java.lang.Object result)
Log a method exit trace statement with a result. |
long |
getConsoleLogLevel()
Returns the raw console logging level. |
int |
getConsoleLogLevelAsInt()
Returns the index of the console logging level. |
java.lang.String |
getFileLogFileName()
Returns the filename used for file logging. |
long |
getFileLogLevel()
Returns the raw file logging level. |
int |
getFileLogLevelAsInt()
Returns the index of the file logging level. |
static java.lang.Object |
getHandler(AbleLogger theLogger,
java.lang.String theHandlerName)
Get a handler from a logger. |
java.util.Enumeration |
getHandlers()
Get an Enumeration of handlers from this logger. |
static AbleLogger |
getMessageLogger(java.lang.String theName,
java.lang.String theDescription)
Return a shared AbleTraceLogger configured for message logging based on the stored preferences. |
static AbleLogger |
getTraceLogger(java.lang.String theName,
java.lang.String theDescription)
Return a shared AbleTraceLogger configured for trace logging based on the stored preferences. |
boolean |
isBeanLogger()
Indicates if the logger is a bean logger; ie, not Able.TraceLog nor Able.MessageLog . |
boolean |
isLogging()
Indicates whether statements are being logged. |
boolean |
isMessageLogger()
Indicates if the logger is a message logger; ie, its output is intended for end-users and is translated. |
boolean |
isTraceLogger()
Indicates if the logger is a trace logger; ie, its output is intended for developers and is untranslated. |
void |
message(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod,
java.lang.String key)
Log a translated message. |
void |
message(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod,
java.lang.String key,
java.lang.Object[] parms)
Log a translated message with multiple substitution parameters. |
void |
message(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod,
java.lang.String key,
java.lang.String parm)
Log a translated message with a single substitution parameter. |
static java.lang.Object |
removeHandler(AbleLogger theLogger,
java.lang.Object theHandler)
|
void |
removeHandler(java.lang.Object theHandler)
Remove a handler from this logger. |
void |
setConsoleLogLevel(long level)
Sets the raw console logging level. |
void |
setFileLogLevel(long level)
Sets the raw file logging level. |
static java.lang.Object |
setHandlerLevel(java.lang.Object handler,
long level)
Sets the logging level for a given handler by creating an AnyMaskFilter. |
void |
setLogging(boolean isLogging)
Sets the flag determining whether logging is on or off. |
static void |
setSimpleFormatter(java.lang.Object theHandler)
Add a simple formatter to provide minimal output. |
void |
stackTrace(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod)
Log a stacktrace. |
static void |
startHandler(java.lang.Object theHandler)
Start a handler's threads. |
static void |
stopHandler(java.lang.Object theHandler)
Stop a handler's threads. |
static void |
stopLogger(AbleLogger theLogger)
Stop a logger by removing all of its handlers and threads. |
void |
text(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod,
java.lang.String text)
Log an untranslated trace statement. |
void |
text(long type,
java.lang.Object loggingClass,
java.lang.String loggingMethod,
java.lang.String text,
java.lang.Object[] parms)
Log an untranslated trace statement with substitution parameters. |
void |
text(long type,
java.lang.String text)
Log an untranslated trace statement. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String TRACE_CONSOLE_HANDLER
public static final java.lang.String TRACE_FILE_HANDLER
public static final java.lang.String TRACE_JTEXTAREA_HANDLER
public static final java.lang.String TRACE_BEAN_CONSOLE_HANDLER
public static final java.lang.String TRACE_BEAN_FILE_HANDLER
public static final java.lang.String TRACE_BEAN_JTEXTAREA_HANDLER
public static final java.lang.String MESSAGE_CONSOLE_HANDLER
public static final java.lang.String MESSAGE_FILE_HANDLER
public static final java.lang.String MESSAGE_JTEXTAREA_HANDLER
public static final java.util.Vector TraceLogLevelValuesVector
Able.TRC_NONE
Able.TRC_LOW
Able.TRC_MEDIUM
Able.TRC_HIGH
public static final java.util.Vector TraceLogLevelLabelsVector
TraceLogLevelValuesVector
.public static final java.util.Vector MessageLogSeverityValuesVector
Able.MSG_NONE
Able.MSG_INFO
Able.MSG_WARNING
Able.MSG_ERROR
public static final java.util.Vector MessageLogSeverityLabelsVector
MessageLogSeverityValuesVector
.protected transient com.ibm.logging.Logger logger
Constructor Detail |
public AbleTraceLogger(java.lang.String theName, java.lang.String theDescription)
theName
- The name of the logger.theDescription
- The description of the logger.public AbleTraceLogger(com.ibm.logging.Logger theLogger)
theLogger
- The source logger, which must not be null.Method Detail |
public static AbleLogger getTraceLogger(java.lang.String theName, java.lang.String theDescription)
theName
- A String containing the name for the logger.theDescription
- A String containing the logger's description.public static AbleLogger getMessageLogger(java.lang.String theName, java.lang.String theDescription)
theName
- A String containing the name for the logger.theDescription
- The logger's description.public static java.lang.Object addConsoleHandler(AbleLogger theLogger, java.lang.String handlerName, long level)
ConsoleHandler
to a logger. If a handler by the name provided exists,
all its filters are removed and a new AnyMaskFilter is calculated from the
level.theLogger
- The logger instance to use the new handler.handlerName
- The name of the handler to add.level
- A level used to calculate the mask for an AnyMaskFilter
.public static java.lang.Object addFileHandler(AbleLogger theLogger, java.lang.String handlerName, long level, java.lang.String filename)
FileHandler
to a logger. If a handler by the name provided exists,
all its filters are removed and a new AnyMaskFilter is calculated from the
level.
If Able.Debug is true, the AbleTraceFormatter is used to display output.theLogger
- The logger instance to use the new handler.handlerName
- A String containing the name of the handler to add.level
- A level used to calculate the mask for an AnyMaskFilter
.filename
- A String containing the path and file name.public static java.lang.Object addHandler(AbleLogger theLogger, java.lang.Object theHandler, long level)
theLogger
- The logger instance to use the new handler.theHandler
- The handler to add.level
- A level used to calculate the mask for an AnyMaskFilter
.public static void setSimpleFormatter(java.lang.Object theHandler)
theHandler
- The IHandler instance to use the formatter. If null,
no action is taken.public long getConsoleLogLevel()
getConsoleLogLevel
in interface AbleLogger
public void setConsoleLogLevel(long level)
setConsoleLogLevel
in interface AbleLogger
public long getFileLogLevel()
getFileLogLevel
in interface AbleLogger
public void setFileLogLevel(long level)
setFileLogLevel
in interface AbleLogger
level
- public java.lang.String getFileLogFileName()
getFileLogFileName
in interface AbleLogger
public int getConsoleLogLevelAsInt()
public int getFileLogLevelAsInt()
public static java.lang.Object removeHandler(AbleLogger theLogger, java.lang.Object theHandler)
public static void stopHandler(java.lang.Object theHandler)
public static void startHandler(java.lang.Object theHandler)
public static void stopLogger(AbleLogger theLogger)
public static java.lang.Object setHandlerLevel(java.lang.Object handler, long level)
handler
- A console or file handler on which to add the filter.level
- A value used to create the mask for the filter.AnyMaskFilter
public boolean isLogging()
isLogging
in interface AbleLogger
public void setLogging(boolean isLogging)
setLogging
in interface AbleLogger
isLogging
- true
if logging is onl false
otherwise.public void message(long type, java.lang.Object loggingClass, java.lang.String loggingMethod, java.lang.String key)
message
in interface AbleLogger
type
- A message record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.key
- The key used to obtain the translated
message from the resource bundle.Able.MSG_ERROR
,
Able.MSG_WARNING
,
Able.MSG_INFO
,
Logger.message(long, java.lang.Object,
java.lang.String, java.lang.String)
public void message(long type, java.lang.Object loggingClass, java.lang.String loggingMethod, java.lang.String key, java.lang.String parm)
message
in interface AbleLogger
type
- A message record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.key
- The key used to obtain the translated
message from the resource bundle.parm
- A substitution value to be inserted into the message.Able.MSG_ERROR
,
Able.MSG_WARNING
,
Able.MSG_INFO
,
Logger.message(long, java.lang.Object,
java.lang.String, java.lang.String)
public void message(long type, java.lang.Object loggingClass, java.lang.String loggingMethod, java.lang.String key, java.lang.Object[] parms)
message
in interface AbleLogger
type
- A message record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.key
- The key used to obtain the translated
message from the resource bundle.parms
- A array of substitution values to be inserted into the message.Able.MSG_ERROR
,
Able.MSG_WARNING
,
Able.MSG_INFO
,
Logger.message(long, java.lang.Object,
java.lang.String, java.lang.String, java.lang.Object[])
public void stackTrace(long type, java.lang.Object loggingClass, java.lang.String loggingMethod)
stackTrace
in interface AbleLogger
type
- A message record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.Able.TRC_LOW
,
Able.TRC_MEDIUM
,
Able.TRC_HIGH
,
Logger.stackTrace(long,Object,String)
public void text(long type, java.lang.String text)
text
in interface AbleLogger
type
- A trace record type.text
- The text to be logged.Logger.text(long,Object,String,String)
public void text(long type, java.lang.Object loggingClass, java.lang.String loggingMethod, java.lang.String text)
text
in interface AbleLogger
type
- A trace record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.text
- The text to be logged.Able.TRC_LOW
,
Able.TRC_MEDIUM
,
Able.TRC_HIGH
,
Logger.text(long,Object,String,String)
public void text(long type, java.lang.Object loggingClass, java.lang.String loggingMethod, java.lang.String text, java.lang.Object[] parms)
text
in interface AbleLogger
type
- A trace record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.text
- The text to be logged.parms
- The array of substitution values to be inserted into the text.Able.TRC_LOW
,
Able.TRC_MEDIUM
,
Able.TRC_HIGH
,
Logger.text(long,Object,String,String,Object[])
public void entry(long type, java.lang.Object loggingClass, java.lang.String loggingMethod)
entry
in interface AbleLogger
type
- A trace record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.Able.TRC_LOW
,
Able.TRC_MEDIUM
,
Able.TRC_HIGH
,
Logger.entry(long,Object,String)
public void entry(long type, java.lang.Object loggingClass, java.lang.String loggingMethod, java.lang.Object parm)
entry
in interface AbleLogger
type
- A trace record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.parm
- The object provided in the method's argument list.Able.TRC_LOW
,
Able.TRC_MEDIUM
,
Able.TRC_HIGH
,
Logger.entry(long,Object,String,Object)
public void entry(long type, java.lang.Object loggingClass, java.lang.String loggingMethod, java.lang.Object[] parms)
entry
in interface AbleLogger
type
- A trace record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.parms
- The objects provided in the method's argument list.Able.TRC_LOW
,
Able.TRC_MEDIUM
,
Able.TRC_HIGH
,
Logger.entry(long,Object,String,Object[])
public void exception(long type, java.lang.Object loggingClass, java.lang.String loggingMethod, java.lang.Throwable throwable)
exception
in interface AbleLogger
type
- A trace record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.throwable
- The exception.Able.TRC_LOW
,
Able.TRC_MEDIUM
,
Able.TRC_HIGH
,
Logger.exception(long,Object,String,Throwable)
public void exit(long type, java.lang.Object loggingClass, java.lang.String loggingMethod)
exit
in interface AbleLogger
type
- A trace record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.Able.TRC_LOW
,
Able.TRC_MEDIUM
,
Able.TRC_HIGH
,
Logger.exit(long,Object,String)
public void exit(long type, java.lang.Object loggingClass, java.lang.String loggingMethod, java.lang.Object result)
exit
in interface AbleLogger
type
- A trace record type.loggingClass
- An instance of a class (this), or a String
containing the package and name if static.loggingMethod
- A string containing the name of the method.result
- The result of the method.Able.TRC_LOW
,
Able.TRC_MEDIUM
,
Able.TRC_HIGH
,
Logger.exit(long,Object,String,Object)
public void addHandler(java.lang.Object theHandler, long level)
addHandler
in interface AbleLogger
theHandler
- The handler to add.LoggerCfg.addHandler(IHandler)
public void removeHandler(java.lang.Object theHandler)
removeHandler
in interface AbleLogger
theHandler
- The handler to remove.LoggerCfg.removeHandler(IHandler)
public java.util.Enumeration getHandlers()
getHandlers
in interface AbleLogger
LoggerCfg.getHandlers()
public static java.lang.Object getHandler(AbleLogger theLogger, java.lang.String theHandlerName)
theLogger
- The logger instance containing the handler to be removed.theHandlerName
- A String containing the name of the handler to remove.TRACE_CONSOLE_HANDLER
,
TRACE_FILE_HANDLER
,
MESSAGE_CONSOLE_HANDLER
,
MESSAGE_FILE_HANDLER
public boolean isBeanLogger()
Able.TraceLog
nor Able.MessageLog
.isBeanLogger
in interface AbleLogger
true
if the logger is a bean logger; false
otherwise.public boolean isTraceLogger()
isTraceLogger
in interface AbleLogger
true
if the logger is a trace logger; false
otherwise.public boolean isMessageLogger()
true
if the logger is a message logger; false
otherwise.public static java.lang.String Copyright()
|
ABLE 2.0.0 07/02/2003 10:25:01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |