Skip to content

Commit

Permalink
Info on console.
Browse files Browse the repository at this point in the history
  • Loading branch information
albertus82 committed Apr 28, 2015
1 parent a0b7a0d commit 525af23
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
28 changes: 24 additions & 4 deletions src/it/albertus/router/RouterLogger.java
Original file line number Diff line number Diff line change
Expand Up @@ -249,21 +249,41 @@ private final void loop() throws IOException, InterruptedException {
// Fine implementazioni specifiche.

// Scrittura indice dell'iterazione in console...
String clean = "";
StringBuilder clean = new StringBuilder();
while (lastLogLength-- > 0) {
clean += '\b';
clean.append('\b');
}
StringBuilder log = new StringBuilder();
boolean animate = Boolean.parseBoolean(configuration.getProperty("logger.animation"));
boolean animate = Boolean.parseBoolean(configuration.getProperty("console.animation"));
if (animate) {
log.append(animation[(iteration & ((1 << 2) - 1))]).append(' ');
}
log.append(iteration).append(' ');
if (animate) {
log.append(animation[(iteration & ((1 << 2) - 1))]).append(' ');
}

// Stampa informazioni aggiuntive richieste...
final StringBuilder infoToShow = new StringBuilder();
for (String key : configuration.getProperty("console.show.keys", "").split(",")) {
key = key.trim();
if (info.containsKey(key)) {
if (infoToShow.length() == 0) {
infoToShow.append('[');
}
else {
infoToShow.append(", ");
}
infoToShow.append(key + ": " + info.get(key));
}
}
if (infoToShow.length() != 0) {
infoToShow.append("] ");
}
log.append(infoToShow);

lastLogLength = log.length();
System.out.print(clean + log.toString());
System.out.print(clean.toString() + log.toString());

// All'ultimo giro non deve esserci il tempo di attesa tra le iterazioni.
if (iteration != iterations) {
Expand Down
6 changes: 5 additions & 1 deletion src/routerlogger.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ threshold.snr.up.key=upstreamNoiseMargin
threshold.snr.up.type=lt
threshold.snr.up.value=150

# Informations to display on console
console.show.keys=downstreamNoiseMargin,downstreamCurrRate

# Destination path
log.destination.dir=c:/users/alberto/desktop

# Application settings
socket.timeout.ms=30000
connection.timeout.ms=30000

Expand All @@ -26,4 +30,4 @@ logger.interval.fast.ms=1000
logger.retry.count=3
logger.retry.interval.ms=60000

logger.animation=true
console.animation=true

0 comments on commit 525af23

Please sign in to comment.