|
|||||||||
Atavism Version 2018.1 | AGIS API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectatavism.server.util.CountLogger
public class CountLogger
This class provides APIs to register and unregister objects which derive from the internal static Counter class. It runs every n milliseconds, as determined by a constructor argument, and when it runs, it interrogates the registered objects, using methods defined on the Counter class, getting the current count and a string. It logs a single line every time it runs. That line contains, for each registered object, the string description of the counter, and the difference between the current count and count during the previous iteration.
Nested Class Summary | |
---|---|
static class |
CountLogger.Counter
The counter class, managed by the CountLogger instance |
Field Summary | |
---|---|
protected java.util.List<CountLogger.Counter> |
counters
|
protected java.lang.Thread |
countLoggerThread
|
protected boolean |
logging
|
protected int |
logLevel
|
protected java.lang.String |
name
|
protected int |
runInterval
|
protected boolean |
running
|
protected boolean |
showAllNonzeroCounters
|
Constructor Summary | |
---|---|
CountLogger(java.lang.String name,
int runInterval,
int logLevel)
The constructor args determine how often the CountLogger instance runs, and at the log level the log lines |
|
CountLogger(java.lang.String name,
int runInterval,
int logLevel,
boolean showAllNonzeroCounters)
The constructor args determine how often the CountLogger instance runs, and at the log level the log lines |
Method Summary | |
---|---|
void |
addCounter(CountLogger.Counter counter)
Add a counter created by calling the Counter constructor to the list of counters |
CountLogger.Counter |
addCounter(java.lang.String name)
Create a counter with the given name and add it to the list of counters |
CountLogger.Counter |
addCounter(java.lang.String name,
long count)
Create a counter with the given name and initial count and add it to the list of counters |
void |
removeCounter(CountLogger.Counter counter)
Remove the Counter arg from the list of counters |
void |
run()
The run method loops sleeping for the run interval, then logs a line containing for each counter the counter name and the count delta since the last time it ran. |
void |
setLogging(boolean enable)
Control generation of log messages. |
void |
start()
Start counter logging thread. |
void |
stop()
Stop counter logging thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.util.List<CountLogger.Counter> counters
protected java.lang.Thread countLoggerThread
protected boolean running
protected java.lang.String name
protected int runInterval
protected int logLevel
protected boolean logging
protected boolean showAllNonzeroCounters
Constructor Detail |
---|
public CountLogger(java.lang.String name, int runInterval, int logLevel)
runInterval
- The number of milliseconds between runslogLevel
- The level at which the information is logged.public CountLogger(java.lang.String name, int runInterval, int logLevel, boolean showAllNonzeroCounters)
name
- Logger name.runInterval
- Milliseconds between runs.logLevel
- The level at which the information is logged.showAllNonzeroCounters
- Method Detail |
---|
public CountLogger.Counter addCounter(java.lang.String name)
public CountLogger.Counter addCounter(java.lang.String name, long count)
public void addCounter(CountLogger.Counter counter)
public void removeCounter(CountLogger.Counter counter)
public void start()
public void stop()
public void setLogging(boolean enable)
public void run()
run
in interface java.lang.Runnable
|
Copyright © 2018 Dragonsan Studios Sp. z o.o. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |