com.atlassian.jira.util.log
Class NShotLogger
java.lang.Object
com.atlassian.jira.util.log.NShotLogger
- Direct Known Subclasses:
- OneShotLogger
public class NShotLogger
- extends Object
An Log4J logger wrapper than will only log N times. After maxTimes number of calls
the logger silently discards the logging output.
The logging is done via a delegate Logger
You might use it a bit like this
private static final Logger log = Logger.getLogger(MyObject.class);
private final Logger oneShotParseErrorLog = new NShotLogger(log,1);
...
...
if (parseErrorOnSomethingThatWeOnlywanToReportOnce == true) {
oneShotParseErrorLog.log("Things seem quite screwy in your config");
}
Note that the logger is not static. If the object in question is a PICO managed singleton
then you will want to use a non static so that the logger will log again if the PICO world is
torn down and brought back up again.
- Since:
- v3.13
Constructor Summary |
NShotLogger(org.apache.log4j.Logger delegateLogger,
int maxTimes)
Creates a NShotLogger that will only output log data if it has been called maxTimes or less. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
NShotLogger
public NShotLogger(org.apache.log4j.Logger delegateLogger,
int maxTimes)
- Creates a NShotLogger that will only output log data if it has been called maxTimes or less.
- Parameters:
delegateLogger
- the delegate Logger that will do the actual loggingmaxTimes
- the maximum number of times that the logger can output logging data.
getDelegateLogger
public org.apache.log4j.Logger getDelegateLogger()
- Returns:
- the underlying delegate Logger
debug
public void debug(Object o)
debug
public void debug(Object o,
Throwable throwable)
error
public void error(Object o)
error
public void error(Object o,
Throwable throwable)
fatal
public void fatal(Object o)
fatal
public void fatal(Object o,
Throwable throwable)
info
public void info(Object o)
info
public void info(Object o,
Throwable throwable)
isDebugEnabled
public boolean isDebugEnabled()
isInfoEnabled
public boolean isInfoEnabled()
isEnabledFor
public boolean isEnabledFor(org.apache.log4j.Priority priority)
warn
public void warn(Object o)
warn
public void warn(Object o,
Throwable throwable)
Copyright © 2002-2014 Atlassian. All Rights Reserved.