public class

NShotLogger

extends Object
java.lang.Object
   ↳ com.atlassian.jira.util.log.NShotLogger
Known Direct Subclasses

Class Overview

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.

Summary

Public Constructors
NShotLogger(Logger delegateLogger, int maxTimes)
Creates a NShotLogger that will only output log data if it has been called maxTimes or less.
Public Methods
void debug(Object o, Throwable throwable)
void debug(Object o)
void error(Object o)
void error(Object o, Throwable throwable)
void fatal(Object o)
void fatal(Object o, Throwable throwable)
Logger getDelegateLogger()
void info(Object o)
void info(Object o, Throwable throwable)
boolean isDebugEnabled()
boolean isEnabledFor(Priority priority)
boolean isInfoEnabled()
void warn(Object o, Throwable throwable)
void warn(Object o)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public NShotLogger (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 logging
maxTimes the maximum number of times that the logger can output logging data.

Public Methods

public void debug (Object o, Throwable throwable)

public void debug (Object o)

public void error (Object o)

public void error (Object o, Throwable throwable)

public void fatal (Object o)

public void fatal (Object o, Throwable throwable)

public Logger getDelegateLogger ()

Returns
  • the underlying delegate Logger

public void info (Object o)

public void info (Object o, Throwable throwable)

public boolean isDebugEnabled ()

public boolean isEnabledFor (Priority priority)

public boolean isInfoEnabled ()

public void warn (Object o, Throwable throwable)

public void warn (Object o)