public class StatisticsLogger
extends java.lang.Object
LoggableStatistics
in order to automatically retrieve figures. Figures are provided by methods returning
double
value figures and annotated as @Loggable.
For example:
class MyStatistics extends LoggableStatistics {
...
@Loggable("SomeFigure")
double getSomeValue() { ... }
...
@Loggable("SomeCount")
double getSomeCount() { ... }
...
}
Statistics are passed to the logger as specified at instantiation time.
StatisticsLogger.LoggableStatistics
Modifier and Type | Class and Description |
---|---|
static interface |
StatisticsLogger.Loggable
Annotation for methods providing some figure in a LoggableStatistics object.
|
static class |
StatisticsLogger.LoggableStatistics
This class provides the support for making a statistics loggable.
|
Constructor and Description |
---|
StatisticsLogger(AbstractLogger logger,
java.lang.String... figures)
Creastes a StatisticsLogger.
|
Modifier and Type | Method and Description |
---|---|
void |
add(java.lang.String prefix,
java.lang.String key,
java.lang.Object value)
Add a value into the current record.
|
void |
close()
Closes the undelying logger.
|
protected void |
finalize() |
AbstractLogger |
getLogger()
Returns the logger used for storing the statistics.
|
void |
log()
Logs a current record by storing it and making the record empty
|
void |
record(StatisticsLogger.LoggableStatistics statistics)
Store a new statistic record in the logger.
|
void |
record(java.lang.String prefix,
StatisticsLogger.LoggableStatistics statistics)
Store a new statistic record in the logger.
|
void |
record(java.lang.String prefix,
StatisticsLogger.LoggableStatistics statistics,
boolean log)
Store a new statistic record in the logger.
|
void |
save()
Saves the undelying logger.
|
public StatisticsLogger(AbstractLogger logger, java.lang.String... figures)
logger
- - the logger used to save the statisticsfigures
- - the figures that we are interested to savepublic void record(StatisticsLogger.LoggableStatistics statistics)
statistics
- - the statistics being logged.public void record(java.lang.String prefix, StatisticsLogger.LoggableStatistics statistics)
prefix
- - the prefix of statistics namestatistics
- - the statistics being logged.public void record(java.lang.String prefix, StatisticsLogger.LoggableStatistics statistics, boolean log)
prefix
- - the prefix of statistics namestatistics
- - the statistics being logged.log
- - if true code> logs a current record by storing it and making the record empty.
public void add(java.lang.String prefix, java.lang.String key, java.lang.Object value)
prefix
- - the prefix of statistics namekey
- - the statistics namevalue
- - the statistics valuepublic AbstractLogger getLogger()
public void log()
public void save()
public void close()
protected void finalize()
finalize
in class java.lang.Object