org.javasimon.callback.logging
Class CounterLogTemplate<C>

java.lang.Object
  extended by org.javasimon.callback.logging.LogTemplate<C>
      extended by org.javasimon.callback.logging.DelegateLogTemplate<C>
          extended by org.javasimon.callback.logging.CounterLogTemplate<C>

public class CounterLogTemplate<C>
extends DelegateLogTemplate<C>

Log template that logs something every N invocations of the isEnabled(Object) method.

Author:
gquintana

Field Summary
private  int counter
          Counter value
private  int counterMax
          Counter max value corresponds to N value
 
Constructor Summary
CounterLogTemplate(LogTemplate delegate, int counterMax)
          Constructor
 
Method Summary
 int getCounter()
          Get counter value
 int getCounterMax()
          Get counter max value, corresponding to logging period
private  boolean incrementCounter()
          Increment counter
 boolean isEnabled(C context)
          Tell whether logging is enabled.
 void log(String message)
          Log a message.
 
Methods inherited from class org.javasimon.callback.logging.DelegateLogTemplate
getDelegate
 
Methods inherited from class org.javasimon.callback.logging.LogTemplate
log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

counterMax

private final int counterMax
Counter max value corresponds to N value


counter

private int counter
Counter value

Constructor Detail

CounterLogTemplate

public CounterLogTemplate(LogTemplate delegate,
                          int counterMax)
Constructor

Parameters:
delegate - Concrete log template
counterMax - Logging period
Method Detail

getCounterMax

public int getCounterMax()
Get counter max value, corresponding to logging period

Returns:
Counter max

getCounter

public int getCounter()
Get counter value

Returns:
Counter

incrementCounter

private boolean incrementCounter()
Increment counter

Returns:
true if counter looped and returned to 0

isEnabled

public boolean isEnabled(C context)
Tell whether logging is enabled.

Overrides:
isEnabled in class DelegateLogTemplate<C>
Returns:
Logging enabled

log

public void log(String message)
Log a message. Increases counter on each call, if delegate log template is enabled

Overrides:
log in class DelegateLogTemplate<C>


Copyright © 2013. All Rights Reserved.