public final class PerfLogger
extends java.lang.Object
Usage:
The above will do nothing if the log level for the logger passed to PerfLogger at construction time is not DEBUG or TRACE - otherwise start() will return the current time in milliseconds and end will issue a log statement if the time between start and end was bigger than 1 ms, and it will pass the parameters to the log statement. The idea is to keep up performance at max possible if the log level is INFO or higher - but to allow some meaningful logging if at DEBUG or TRACe. The difference between DEBUG and TRACE is that TRACE will log start too (if a log message is passed to start) and it will always log the end - whereas in case of DEBUG the start will never be logged and the end will only be logged if the time is bigger than what's passed to end.
Constructor and Description |
---|
PerfLogger(Logger delegate)
Create a new PerfLogger that shall use the given Logger object for logging
|
Modifier and Type | Method and Description |
---|---|
void |
end(long start,
long logAtDebugIfSlowerThanMs,
long logAtInfoIfSlowerThanMs,
java.lang.String logMessagePrefix,
java.lang.Object... arguments)
Returns quickly if start is negative (which is the case according to log level
at the time of
start() or startForInfoLog() ). |
void |
end(long start,
long logAtDebugIfSlowerThanMs,
long logAtInfoIfSlowerThanMs,
java.lang.String logMessagePrefix,
java.lang.Object arg1)
See
end(long, long, long, String, Object...)
Note that this method exists for performance optimization only (compared
to the other end() method with a vararg. |
void |
end(long start,
long logAtDebugIfSlowerThanMs,
long logAtInfoIfSlowerThanMs,
java.lang.String logMessagePrefix,
java.lang.Object arg1,
java.lang.Object arg2)
See
end(long, long, long, String, Object...)
Note that this method exists for performance optimization only (compared
to the other end() method with a vararg. |
void |
end(long start,
long logAtDebugIfSlowerThanMs,
java.lang.String logMessagePrefix,
java.lang.Object... arguments)
|
void |
end(long start,
long logAtDebugIfSlowerThanMs,
java.lang.String logMessagePrefix,
java.lang.Object arg1)
See
end(long, long, long, String, Object...)
Note that this method exists for performance optimization only (compared
to the other end() method with a vararg. |
void |
end(long start,
long logAtDebugIfSlowerThanMs,
java.lang.String logMessagePrefix,
java.lang.Object arg1,
java.lang.Object arg2)
See
end(long, long, long, String, Object...)
Note that this method exists for performance optimization only (compared
to the other end() method with a vararg. |
boolean |
isDebugEnabled()
Whether or not the delegate has log level DEBUG configured
|
boolean |
isInfoEnabled()
Whether or not the delegate has log level INFO configured
|
boolean |
isTraceEnabled()
Whether or not the delegate has log level TRACE configured
|
long |
start()
Shortcut to
#start(null, false) |
long |
start(java.lang.String traceMsgOrNull)
Shortcut to
start(traceMsgOrNull, false) |
long |
startForInfoLog()
Shortcut to
start(null, true) |
long |
startForInfoLog(java.lang.String traceMsgOrNull)
Shortcut to
start(traceMsgOrNull, true) |
public PerfLogger(Logger delegate)
public final long start()
#start(null, false)
public final long startForInfoLog()
start(null, true)
public final long start(java.lang.String traceMsgOrNull)
start(traceMsgOrNull, false)
public final long startForInfoLog(java.lang.String traceMsgOrNull)
start(traceMsgOrNull, true)
public final void end(long start, long logAtDebugIfSlowerThanMs, java.lang.String logMessagePrefix, java.lang.Object arg1)
end(long, long, long, String, Object...)
Note that this method exists for performance optimization only (compared
to the other end() method with a vararg.public final void end(long start, long logAtDebugIfSlowerThanMs, java.lang.String logMessagePrefix, java.lang.Object arg1, java.lang.Object arg2)
end(long, long, long, String, Object...)
Note that this method exists for performance optimization only (compared
to the other end() method with a vararg.public void end(long start, long logAtDebugIfSlowerThanMs, java.lang.String logMessagePrefix, java.lang.Object... arguments)
public final void end(long start, long logAtDebugIfSlowerThanMs, long logAtInfoIfSlowerThanMs, java.lang.String logMessagePrefix, java.lang.Object arg1)
end(long, long, long, String, Object...)
Note that this method exists for performance optimization only (compared
to the other end() method with a vararg.public final void end(long start, long logAtDebugIfSlowerThanMs, long logAtInfoIfSlowerThanMs, java.lang.String logMessagePrefix, java.lang.Object arg1, java.lang.Object arg2)
end(long, long, long, String, Object...)
Note that this method exists for performance optimization only (compared
to the other end() method with a vararg.public void end(long start, long logAtDebugIfSlowerThanMs, long logAtInfoIfSlowerThanMs, java.lang.String logMessagePrefix, java.lang.Object... arguments)
start()
or startForInfoLog()
).
If log level is set to TRACE, log.trace is always emitted.
If log level is set to DEBUG, then log.debug is emitted if 'now' is bigger (slower)
than start
by at least logAtDebugIfSlowerThanMs
.
If log level is set to INFO, then long.info is emitted if 'now' is bigger (slower)
than start
by at least logAtInfoIfSlowerThanMs
.start
- the start time with which 'now' should be comparedlogAtDebugIfSlowerThanMs
- the number of milliseconds that must
be surpassed to issue a log.debug (if log level is DEBUG)logAtInfoIfSlowerThanMs
- the number of milliseconds that must
be surpassed to issue a log.info (if log level is DEBUG)logMessagePrefix
- the log message 'prefix' - to which the given
arguments will be passed, plus the measured time difference in the format
'[took x ms']arguments
- the arguments which is to be passed to the log statementpublic final boolean isInfoEnabled()
public final boolean isDebugEnabled()
public final boolean isTraceEnabled()
Copyright © 2010 - 2020 Adobe. All Rights Reserved