public class NShotLogger extends Object
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.
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
void |
debug(Object o) |
void |
debug(Object o,
Throwable throwable) |
void |
error(Object o) |
void |
error(Object o,
Throwable throwable) |
void |
fatal(Object o) |
void |
fatal(Object o,
Throwable throwable) |
org.apache.log4j.Logger |
getDelegateLogger() |
void |
info(Object o) |
void |
info(Object o,
Throwable throwable) |
boolean |
isDebugEnabled() |
boolean |
isEnabledFor(org.apache.log4j.Priority priority) |
boolean |
isInfoEnabled() |
void |
warn(Object o) |
void |
warn(Object o,
Throwable throwable) |
public NShotLogger(org.apache.log4j.Logger delegateLogger, int maxTimes)
delegateLogger
- the delegate Logger that will do the actual loggingmaxTimes
- the maximum number of times that the logger can output logging data.public org.apache.log4j.Logger getDelegateLogger()
public void debug(Object o)
public void error(Object o)
public void fatal(Object o)
public void info(Object o)
public boolean isDebugEnabled()
public boolean isInfoEnabled()
public boolean isEnabledFor(org.apache.log4j.Priority priority)
public void warn(Object o)
Copyright © 2002-2015 Atlassian. All Rights Reserved.