Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enabled pubber options to startup log #369

Merged
merged 4 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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