Skip to content

Commit

Permalink
Add enabled pubber options to pubber startup log (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
noursaidi committed Jun 27, 2022
1 parent 845662c commit b553a3d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
27 changes: 27 additions & 0 deletions pubber/src/main/java/daq/pubber/ConfigurationOptions.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package daq.pubber;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

/**
* Pubber configuration options which change default behavior.
*/
Expand All @@ -8,4 +14,25 @@ public class ConfigurationOptions {
public String extraPoint;
public String extraField;

/**
* Returns a string of enabled options and values.
*/
public String toString() {
List<String> options = new ArrayList<>();
Field[] fields = ConfigurationOptions.class.getDeclaredFields();

for (Field field : fields) {
try {
if (field.get(this) != null && Boolean.TRUE.equals(field.get(this))) {
options.add(field.getName());
} else if (field.get(this) != null) {
options.add(field.getName() + "=" + field.get(this));
}
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
return String.join(" ", options);
}

}
4 changes: 2 additions & 2 deletions pubber/src/main/java/daq/pubber/Pubber.java
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,9 @@ private void initializeDevice() {
pullDeviceMessage();
}

info(String.format("Starting pubber %s, serial %s, mac %, gateway %s",
info(String.format("Starting pubber %s, serial %s, mac %s, gateway %s, options %s",
configuration.deviceId, configuration.serialNo, configuration.macAddr,
configuration.gatewayId));
configuration.gatewayId, configuration.options));

deviceState.system.operational = true;
deviceState.system.serial_no = configuration.serialNo;
Expand Down

0 comments on commit b553a3d

Please sign in to comment.