public class Trace
extends com.streamscape.sef.trace.AbstractTrace
Title: Package Trace Facility
Description: Defines a deep tracing facility that provides internal logging of debug messages.
The internal Trace facility may be configured either by a direct call to enable(String, com.streamscape.Trace.Level)
method or may be set by JVM System Properties at start-up. Parameters allow the trace to be set on a system-wide
level by central facilities like a run-time a context or container.
In order to enable the trace facility for printing debug information users specify at start-up which classes
will emit trace information.
For example: -Dcom.streamscape.Trace.debug=className,className,...
.
The class names can be fully qualified or can include a wild card * at the end to include whole package.
For example: -Dcom.streamscape.Trace.debug=com.streamscape.sef.*
.
Also you can supply a wild card * to include all classes: -Dcom.streamscape.Trace.info=*
.
Deep tracing is intended for use as a debug mechanism by developers that need to trace logic flow of core components not normally exposed to developers. It is not intended as a logging facility for Fabric Components. The trace may be re-routed to a configurable logger and may provide extremely detailed information. As a general rule, deep tracing should always be disabled for production code due to the amount of logging content that is generated.
Trace Options:
com.streamscape.Trace.debug
- Level 3 trace that provides informational, error and debug tracingcom.streamscape.Trace.info
- Level 2 trace that provides informational and error tracingcom.streamscape.Trace.error
- Level 1 trace that provides error tracingCopyright: Copyright (c) 2008
Company: StreamScape Technologies
Modifier and Type | Class and Description |
---|---|
static class |
Trace.Level |
Modifier and Type | Method and Description |
---|---|
static void |
disable(java.lang.String className)
Disables the trace for for the specified class or package.
|
static void |
enable(java.lang.String className,
Trace.Level level)
Enables the trace of the specified level for for the specified class or package.
|
static java.util.List |
getClasses()
Returns a list of names of classes or packages for which the trace is enabled.
|
static RowSet |
getConfiguration()
Returns a
RowSet containing a set of pairs <Class,Level>,
for each class or package for which the trace is enabled. |
static java.io.File |
getConfigurationFile()
Returns the configuration file containing rules for enabling the trace.
|
static java.lang.String |
getDateFormat()
Returns the date format.
|
static Trace.Level |
getLevel(java.lang.String className)
Returns the trace level enabled for the specified class or package.
|
static Logger |
getLogger(java.lang.String className)
Returns the logger of the specified class or package.
|
static java.util.TimeZone |
getTimeZone()
Returns the time zone of the date format.
|
static boolean |
isBroadcastEnabled(java.lang.String className)
Checks if a broadcast of Log Events is enabled for the specified class or package.
|
static boolean |
isDebugEnabled(java.lang.Class clazz)
Checks if the trace level
Trace.Level.DEBUG is enabled for the specified class. |
static boolean |
isDebugEnabled(java.lang.String className)
Checks if the trace level
Trace.Level.DEBUG is enabled for the specified class or package. |
static boolean |
isEnabled(java.lang.Class clazz,
Trace.Level level)
Checks if the trace of the specified level is enabled for the specified class.
|
static boolean |
isEnabled(java.lang.String className)
Checks if the trace is enabled for the specified class or package.
|
static boolean |
isEnabled(java.lang.String className,
Trace.Level level)
Checks if the trace of the specified level is enabled for the specified class or package.
|
static boolean |
isErrorEnabled(java.lang.Class clazz)
Checks if the trace level
Trace.Level.ERROR is enabled for the specified class. |
static boolean |
isErrorEnabled(java.lang.String className)
Checks if the trace level
Trace.Level.ERROR is enabled for the specified class or package. |
static boolean |
isInfoEnabled(java.lang.Class cls)
Checks if the trace level
Trace.Level.INFO is enabled for the specified class. |
static boolean |
isInfoEnabled(java.lang.String className)
Checks if the trace level
Trace.Level.INFO is enabled for the specified class or package. |
static boolean |
log(java.lang.Object source,
Trace.Level level,
java.lang.String message,
java.lang.Object[] args)
Logs the specified debug message for the specified source (class or object) with specified log level.
|
static boolean |
logDebug(java.lang.Object source,
java.lang.String message)
Logs the specified debug message for the specified source (class or object).
|
static boolean |
logDebug(java.lang.Object source,
java.lang.String message,
java.lang.Object[] args)
Logs the specified debug message for the specified source (class or object).
|
static boolean |
logError(java.lang.Object source,
java.lang.String message)
Logs the specified error message for the specified source (class or object).
|
static boolean |
logError(java.lang.Object source,
java.lang.String message,
java.lang.Object[] args)
Logs the specified error message for the specified source (class or object).
|
static boolean |
logException(java.lang.Object source,
java.lang.Throwable exception,
boolean printStackTrace)
Logs the specified exception for the specified source (class or object).
|
static boolean |
logInfo(java.lang.Object source,
java.lang.String message)
Logs the specified info message for the specified source (class or object).
|
static boolean |
logInfo(java.lang.Object source,
java.lang.String message,
java.lang.Object[] args)
Logs the specified info message for the specified source (class or object).
|
static void |
setBroadcast(java.lang.String className,
boolean broadcast)
Enables/disables a broadcast of Log Events for the specified class or package.
|
static void |
setConfigurationFile(java.lang.String filename)
Sets the configuration file containing rules for enabling the trace.
|
static void |
setDateFormat(java.lang.String pattern)
Sets a date format using the specified pattern (default is "MM/dd/yy HH:mm:ss.SSS").
|
static void |
setLogger(java.lang.String className,
Logger logger)
Sets the specified logger of the specified class or package.
|
static void |
setTimeZone(java.util.TimeZone timeZone)
Sets the specified time zone to the date format.
|
public static void enable(java.lang.String className, Trace.Level level)
className
has the format <packageName>.*, the trace will be enabled
for all classes contained in the package packageName.
className
is *
, the trace will be enabled for all classes.
// Enables ERROR level for all classes. Trace.enable("*", Trace.Level.ERROR); // Enables INFO level for all classes incom.streamscape.lib
package. Trace.enable("com.streamscape.lib.*", Trace.Level.INFO); // Enables DEBUG level forcom.streamscape.cli.tlp.FabricConnection
class. Trace.enable("com.streamscape.cli.tlp.FabricConnection", Trace.Level.DEBUG);
className
- the name of the specified class or package.level
- the Trace level to be enabled.public static void disable(java.lang.String className)
enable(String, com.streamscape.Trace.Level)
), this method does nothing.
className
has the format <packageName>.*, printing of debug messages will be disabled
for all classes containing in the package packageName.
className
is *, the trace will be disabled for all classes.className
- the name of the specified class or package.public static boolean isEnabled(java.lang.String className)
className
can contain '*' character (see enable(String, com.streamscape.Trace.Level)
} for details).className
- the name of the specified class or package.true
if printing debug messages is enabled for the specified class, false
otherwise.public static Trace.Level getLevel(java.lang.String className)
null
.
className
can contain '*' character (see enable(String, com.streamscape.Trace.Level)
} for details).className
- the name of the specified class or package.null
if the trace is not enabled.public static boolean isEnabled(java.lang.Class clazz, Trace.Level level)
clazz
- the specified class.level
- the specified trace level.true
if the trace level is enabled for the class, false
otherwise.public static boolean isEnabled(java.lang.String className, Trace.Level level)
className
can contain '*' character (see enable(String, com.streamscape.Trace.Level)
} for details).className
- the name of the specified class or package.level
- the specified trace level.true
if the trace level is enabled for the class or package, false
otherwise.public static boolean isErrorEnabled(java.lang.Class clazz)
Trace.Level.ERROR
is enabled for the specified class.clazz
- the specified class.true
if the trace level Trace.Level.ERROR
is enabled for specified class, false
otherwise.public static boolean isErrorEnabled(java.lang.String className)
Trace.Level.ERROR
is enabled for the specified class or package.
className
can contain '*' character (see enable(String, com.streamscape.Trace.Level)
} for details).className
- the name of the specified class or package.true
if the trace level Trace.Level.ERROR
is enabled for specified class, false
otherwise.public static boolean isInfoEnabled(java.lang.Class cls)
Trace.Level.INFO
is enabled for the specified class.cls
- the specified class.true
if the trace level Trace.Level.INFO
is enabled for specified class, false
otherwise.public static boolean isInfoEnabled(java.lang.String className)
Trace.Level.INFO
is enabled for the specified class or package.
className
can contain '*' character (see enable(String, com.streamscape.Trace.Level)
} for details).className
- the name of the specified class or package.true
if the trace level Trace.Level.INFO
is enabled for specified class, false
otherwise.public static boolean isDebugEnabled(java.lang.Class clazz)
Trace.Level.DEBUG
is enabled for the specified class.clazz
- the specified class.true
if if the trace level Trace.Level.DEBUG
is enabled, false
otherwise.public static boolean isDebugEnabled(java.lang.String className)
Trace.Level.DEBUG
is enabled for the specified class or package.
className
can contain '*' character (see enable(String, com.streamscape.Trace.Level)
} for details).className
- the name of the specified class or package.true
if the trace level Trace.Level.DEBUG
is enabled for specified class, false
otherwise.public static void setLogger(java.lang.String className, Logger logger)
enable(String, com.streamscape.Trace.Level)
),
corresponding debug messages will be passed to this logger.
className
can contain '*' character (see enable(String, com.streamscape.Trace.Level)
} for details).
If the logger
is null
, the current logger for the specified class will be unset.
If a non-null logger is set for any parent package it will be used for the specified class.
// Sets theGlobalLogger
for all classes. All debug messages will be passed to this logger. Trace.setLogger("*", new GlobalLogger()); // Sets theUserLogger1
for all classes from thecom.streamscape.sef
package. // Debug messages for all classes from this package will be passed to theUserLogger1
logger. // Other debug messages will be passed to theGlobalLogger
. Trace.setLogger("com.streamscape.sef.*", new UserLogger1()); // Sets theUserLogger2
for thecom.streamscape.sef.container.Container
class. // Debug messages for this class will be passed to theUserLogger2
logger. // Other debug messages will be passed to theUserLogger1
andGlobalLogger
loggers. Trace.enable("com.streamscape.sef.container.Container", new UserLogger2());
className
- the name of specified class or package.logger
- the logger to be set.public static Logger getLogger(java.lang.String className)
className
can contain '*' character (see enable(String, com.streamscape.Trace.Level)
} for details).className
- the name of specified class or package.null
if such logger is not set.public static void setBroadcast(java.lang.String className, boolean broadcast)
className
can use '*' character (see enable(String, com.streamscape.Trace.Level)
} for details).
Log Event is an instance of MapEvent
, containing a debug message.
The event has the event id event.log.Trace
and the following event properties:
sourceType - type of the node where the debug message has been produced.
sourceName - name of the node where the debug message has been produced.
timestamp - timestamp of the debug message.
level - level of the debug message.
className - name of the class that produced the debug message.
message - the debug message.
className
- the name of specified class or package.broadcast
- the broadcast flag to be set (true
means enabling the broadcast, false
means disabling).public static boolean isBroadcastEnabled(java.lang.String className)
className
can use '*' character (see enable(String, com.streamscape.Trace.Level)
} for details).className
- the name of specified class or package.true
if the broadcast is enabled for the specified class or package, false
otherwise.public static java.lang.String getDateFormat()
pattern
- the pattern defining a date format.public static void setDateFormat(java.lang.String pattern)
pattern
- the pattern defining a date format to be set.public static java.util.TimeZone getTimeZone()
timeZone
- the time zone.public static void setTimeZone(java.util.TimeZone timeZone)
timeZone
- the time zone to be set.public static java.util.List getClasses()
public static RowSet getConfiguration()
RowSet
containing a set of pairs <Class,Level>,
for each class or package for which the trace is enabled.public static void setConfigurationFile(java.lang.String filename)
<ClassName> error|info|debug
,
where the ClassName
can use '*' character (see enable(String, com.streamscape.Trace.Level)
} for details).
Trace
configuration (enabling or disabling of tracing) will be saved in this configuration file.
tnode.traces
.
* error com.streamscape.lib.* info com.streamscape.runtime.* debug com.streamscape.sdo.* info com.streamscape.sef.* info
filename
- the path to configuration file.public static java.io.File getConfigurationFile()
null
if the trace has no configuration file.public static boolean logError(java.lang.Object source, java.lang.String message)
source
- the source of logged message.message
- the message to be logged.true
if the message has been really logged (i.e. matched the rules), false
otherwise.public static boolean logError(java.lang.Object source, java.lang.String message, java.lang.Object[] args)
source
- the source of logged message.message
- the message to be logged.args
- {} placeholders in the source message will be replaced with args.true
if the message has been really logged (i.e. matched the rules), false
otherwise.public static boolean logInfo(java.lang.Object source, java.lang.String message)
source
- the source of logged message.message
- the message to be logged.true
if the message has been really logged (i.e. matched the rules), false
otherwise.public static boolean logInfo(java.lang.Object source, java.lang.String message, java.lang.Object[] args)
source
- the source of logged message.message
- the message to be logged.args
- {} placeholders in the source message will be replaced with args.true
if the message has been really logged (i.e. matched the rules), false
otherwise.public static boolean logDebug(java.lang.Object source, java.lang.String message)
source
- the source of logged message.message
- the message to be logged.true
if the message has been really logged (i.e. matched the rules), false
otherwise.public static boolean logDebug(java.lang.Object source, java.lang.String message, java.lang.Object[] args)
source
- the source of logged message.message
- the message to be logged.args
- {} placeholders in the source message will be replaced with args.true
if the message has been really logged (i.e. matched the rules), false
otherwise.public static boolean logException(java.lang.Object source, java.lang.Throwable exception, boolean printStackTrace)
source
- the source of logged message.exception
- the exception to be logged.printStackTrace
- indicates if a stack trace of the exception will be logged.true
if the message has been really logged (i.e. matched the rules), false
otherwise.public static boolean log(java.lang.Object source, Trace.Level level, java.lang.String message, java.lang.Object[] args)
source
- the source of logged message.level
- the log level.message
- the message to be logged.args
- {} placeholders in the source message will be replaced with args.true
if the message has been really logged (i.e. matched the rules), false
otherwise.Copyright © 2015-2024 StreamScape Technologies. All rights reserved.