|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.perf4j.StopWatch
org.perf4j.LoggingStopWatch
org.perf4j.slf4j.Slf4JStopWatch
public class Slf4JStopWatch
This LoggingStopWatch uses an SLF4J Logger instance to persist the StopWatch messages.
Field Summary | |
---|---|
static int |
DEBUG_LEVEL
Specifying this level will cause the debug() method to be used for logging. |
static int |
ERROR_LEVEL
Specifying this level will cause the error() method to be used for logging. |
static int |
INFO_LEVEL
Specifying this level will cause the info() method to be used for logging. |
static int |
TRACE_LEVEL
Specifying this level will cause the trace() method to be used for logging. |
static int |
WARN_LEVEL
Specifying this level will cause the warn() method to be used for logging. |
Fields inherited from class org.perf4j.StopWatch |
---|
DEFAULT_LOGGER_NAME |
Constructor Summary | |
---|---|
Slf4JStopWatch()
Creates a Slf4JStopWatch with a blank tag, no message and started at the instant of creation. |
|
Slf4JStopWatch(Logger logger)
Creates a Slf4JStopWatch with a blank tag, no message and started at the instant of creation, using the specified Logger to log stop watch messages using the info() method, or using the warn() method if an exception is passed to one of the stop or lap methods. |
|
Slf4JStopWatch(Logger logger,
int normalPriority)
Creates a Slf4JStopWatch with a blank tag, no message and started at the instant of creation, using the specified Logger to log stop watch messages at the normalPriority level specified, or using the warn() method if an exception is passed to one of the stop or lap methods. |
|
Slf4JStopWatch(Logger logger,
int normalPriority,
int exceptionPriority)
Creates a Slf4JStopWatch with a blank tag, no message and started at the instant of creation, using the specified Logger to log stop watch messages at the normalPriority level specified, or at the exceptionPriority level if an exception is passed to one of the stop or lap methods. |
|
Slf4JStopWatch(long startTime,
long elapsedTime,
String tag,
String message,
Logger logger,
int normalPriority,
int exceptionPriority)
This constructor is mainly used for creation of StopWatch instances from logs and for testing. |
|
Slf4JStopWatch(String tag)
Creates a Slf4JStopWatch with the tag specified, no message and started at the instant of creation. |
|
Slf4JStopWatch(String tag,
Logger logger)
Creates a Slf4JStopWatch with the tag specified, no message and started at the instant of creation, using the specified Logger to log stop watch using the info() method, or using the warn() method if an exception is passed to one of the stop or lap methods. |
|
Slf4JStopWatch(String tag,
Logger logger,
int normalPriority)
Creates a Slf4JStopWatch with the tag specified, no message and started at the instant of creation, using the specified Logger to log stop watch messages at the normalPriority level specified, or using the warn() level if an exception is passed to one of the stop or lap methods. |
|
Slf4JStopWatch(String tag,
Logger logger,
int normalPriority,
int exceptionPriority)
Creates a Slf4JStopWatch with the tag specified, no message and started at the instant of creation, using the specified Logger to log stop watch messages at the normalPriority level specified, or at the exceptionPriority level if an exception is passed to one of the stop or lap methods. |
|
Slf4JStopWatch(String tag,
String message)
Creates a Slf4JStopWatch with the tag and message specified and started at the instant of creation. |
|
Slf4JStopWatch(String tag,
String message,
Logger logger)
Creates a Slf4JStopWatch with the tag and message specified and started at the instant of creation, using the specified Logger to log stop watch messages using the info() method, or using the warn() method if an exception is passed to one of the stop or lap methods. |
|
Slf4JStopWatch(String tag,
String message,
Logger logger,
int normalPriority)
Creates a Slf4JStopWatch with the tag and message specified and started at the instant of creation, using the specified Logger to log stop watch messages at the normalPriority level specified, or using the warn() method if an exception is passed to one of the stop or lap methods. |
|
Slf4JStopWatch(String tag,
String message,
Logger logger,
int normalPriority,
int exceptionPriority)
Creates a Slf4JStopWatch with the tag and message specified and started at the instant of creation, using the specified Logger to log stop watch messages at the normalPriority level specified, or at the exceptionPriority level if an exception is passed to one of the stop or lap methods. |
Method Summary | |
---|---|
Slf4JStopWatch |
clone()
|
int |
getExceptionPriority()
Gets the level at which log statements will be made when one of the stop or lap methods that DOES take an exception is called. |
Logger |
getLogger()
Gets the Apache Commons Logging Logger that is used to persist logging statements when one of the stop or lap methods is called. |
int |
getNormalPriority()
Gets the level at which log statements will be made when one of the stop or lap methods that does NOT take an exception is called. |
boolean |
isLogging()
This method returns true if the Logger it uses is enabled at the normalPriority level of this StopWatch. |
protected boolean |
isLogging(int atLevel)
Since Commons Logging doesn't have a first class notion of Level objects or integer values, this method converts the level value to one of the isXYZEnabled() methods on the Log. |
protected void |
log(String stopWatchAsString,
Throwable exception)
The log message is overridden to use the Apache Commons Logging Logger to persist the stop watch. |
protected void |
log(String stopWatchAsString,
Throwable exception,
int atLevel)
Since Commons Logging doesn't have a first class notion of Level objects or integer values, this method maps the atLevel parameter to one of the trace(), debug(), info(), warn(), error(), or fatal() methods on the Log. |
static int |
mapLevelName(String levelName)
This utility method provides the standard mapping between log4j level names (which Perf4J uses as the standard set of possible levels) to the corresponding ..._LEVEL constant from this class. |
void |
setExceptionPriority(int exceptionPriority)
Sets the level at which log statements will be made when one of the stop or lap methods that DOES take an exception is called. |
void |
setLogger(Logger logger)
Sets the Apache Commons Logging Logused to persist StopWatch instances. |
void |
setNormalPriority(int normalPriority)
Sets the level at which log statements will be made when one of the stop or lap methods that does NOT take an exception is called. |
Methods inherited from class org.perf4j.LoggingStopWatch |
---|
lap, lap, stop, stop, stop, stop |
Methods inherited from class org.perf4j.StopWatch |
---|
equals, getElapsedTime, getMessage, getStartTime, getTag, hashCode, lap, lap, setMessage, setTag, start, start, start, stop, stop, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int TRACE_LEVEL
public static final int DEBUG_LEVEL
public static final int INFO_LEVEL
public static final int WARN_LEVEL
public static final int ERROR_LEVEL
Constructor Detail |
---|
public Slf4JStopWatch()
public Slf4JStopWatch(Logger logger)
logger
- The Logger to use when persisting StopWatches in one of the stop or lap methods.public Slf4JStopWatch(Logger logger, int normalPriority)
logger
- The Logger to use when persisting StopWatches in one of the stop or lap methods.normalPriority
- The level at which this StopWatch is logged if one of the stop or lap methods that does
NOT take an exception is called. Should be one of the ..._LEVEL constants from this class.public Slf4JStopWatch(Logger logger, int normalPriority, int exceptionPriority)
logger
- The Logger to use when persisting StopWatches in one of the stop or lap methods.normalPriority
- The level at which this StopWatch is logged if one of the stop or lap methods that does
NOT take an exception is called. Should be one of the ..._LEVEL constants from this
class.exceptionPriority
- The level at which this StopWatch is logged if one of the stop or lap methods that DOES
take an exception is called. Should be one of the ..._LEVEL constants from this class.public Slf4JStopWatch(String tag)
tag
- The tag name for this timing call. Tags are used to group timing logs, thus each block
of code being timed should have a unique tag. Note that tags can take a hierarchical
format using dot notation.public Slf4JStopWatch(String tag, Logger logger)
tag
- The tag name for this timing call. Tags are used to group timing logs, thus each block
of code being timed should have a unique tag. Note that tags can take a hierarchical
format using dot notation.logger
- The Logger to use when persisting StopWatches in one of the stop or lap methods.public Slf4JStopWatch(String tag, Logger logger, int normalPriority)
tag
- The tag name for this timing call. Tags are used to group timing logs, thus each block
of code being timed should have a unique tag. Note that tags can take a hierarchical
format using dot notation.logger
- The Logger to use when persisting StopWatches in one of the stop or lap methods.normalPriority
- The level at which this StopWatch is logged if one of the stop or lap methods that does
NOT take an exception is called. Should be one of the ..._LEVEL constants from this class.public Slf4JStopWatch(String tag, Logger logger, int normalPriority, int exceptionPriority)
tag
- The tag name for this timing call. Tags are used to group timing logs, thus each block
of code being timed should have a unique tag. Note that tags can take a hierarchical
format using dot notation.logger
- The Logger to use when persisting StopWatches in one of the stop or lap methods.normalPriority
- The level at which this StopWatch is logged if one of the stop or lap methods that does
NOT take an exception is called. Should be one of the ..._LEVEL constants from this
class.exceptionPriority
- The level at which this StopWatch is logged if one of the stop or lap methods that DOES
take an exception is called. Should be one of the ..._LEVEL constants from this class.public Slf4JStopWatch(String tag, String message)
tag
- The tag name for this timing call. Tags are used to group timing logs, thus each block
of code being timed should have a unique tag. Note that tags can take a hierarchical
format using dot notation.message
- Additional text to be printed with the logging statement of this StopWatch.public Slf4JStopWatch(String tag, String message, Logger logger)
tag
- The tag name for this timing call. Tags are used to group timing logs, thus each block
of code being timed should have a unique tag. Note that tags can take a hierarchical
format using dot notation.message
- Additional text to be printed with the logging statement of this StopWatch.logger
- The Logger to use when persisting StopWatches in one of the stop or lap methods.public Slf4JStopWatch(String tag, String message, Logger logger, int normalPriority)
tag
- The tag name for this timing call. Tags are used to group timing logs, thus each block
of code being timed should have a unique tag. Note that tags can take a hierarchical
format using dot notation.message
- Additional text to be printed with the logging statement of this StopWatch.logger
- The Logger to use when persisting StopWatches in one of the stop or lap methods.normalPriority
- The level at which this StopWatch is logged if one of the stop or lap methods that does
NOT take an exception is called. Should be one of the ..._LEVEL constants from this class.public Slf4JStopWatch(String tag, String message, Logger logger, int normalPriority, int exceptionPriority)
tag
- The tag name for this timing call. Tags are used to group timing logs, thus each block
of code being timed should have a unique tag. Note that tags can take a hierarchical
format using dot notation.message
- Additional text to be printed with the logging statement of this StopWatch.logger
- The Logger to use when persisting StopWatches in one of the stop or lap methods.normalPriority
- The level at which this StopWatch is logged if one of the stop or lap methods that does
NOT take an exception is called. Should be one of the ..._LEVEL constants from this
class.exceptionPriority
- The level at which this StopWatch is logged if one of the stop or lap methods that DOES
take an exception is called. Should be one of the ..._LEVEL constants from this class.public Slf4JStopWatch(long startTime, long elapsedTime, String tag, String message, Logger logger, int normalPriority, int exceptionPriority)
startTime
- The start time in millisecondselapsedTime
- The elapsed time in millisecondstag
- The tag used to group timing logs of the same code blockmessage
- Additional message textlogger
- The Logger to use when persisting StopWatches in one of the stop or lap methods.normalPriority
- The level at which this StopWatch is logged if one of the stop or lap methods that does
NOT take an exception is called.exceptionPriority
- The level at which this StopWatch is logged if one of the stop or lap methods that DOES
take an exception is called.Method Detail |
---|
public Logger getLogger()
public void setLogger(Logger logger)
logger
- The Logger this instance should use for persistence. May not be null.public int getNormalPriority()
public void setNormalPriority(int normalPriority)
normalPriority
- The level used when logging "normal" stop or lap calls. This value should be one of the
..._LEVEL constants of this class.public int getExceptionPriority()
public void setExceptionPriority(int exceptionPriority)
exceptionPriority
- The level used when logging "exceptional" stop or lap calls. This value should be one
of the ..._LEVEL constants of this class.public boolean isLogging()
isLogging
in class LoggingStopWatch
protected void log(String stopWatchAsString, Throwable exception)
log
in class LoggingStopWatch
stopWatchAsString
- The stringified view of the stop watch for logging.exception
- An exception, if any, that was passed to the stop or lap method. If this is null then
logging will occur at normalPriority, if non-null it will occur at exceptionPriority.protected boolean isLogging(int atLevel)
atLevel
- The level at which a log message is logged.
protected void log(String stopWatchAsString, Throwable exception, int atLevel)
stopWatchAsString
- The stringified view of the stop watch for logging.exception
- An exception, if any, that was passed to the stop or lap method. If this is null then
logging will occur at normalPriority, if non-null it will occur at exceptionPriority.atLevel
- The level at which logging should occur.public static int mapLevelName(String levelName)
levelName
- The name of the logging level, should be one of TRACE, DEBUG, INFO, WARN, ERROR or FATAL.
public Slf4JStopWatch clone()
clone
in class LoggingStopWatch
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |