Skip to content

Commit

Permalink
feat: improve output of metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
metacosm committed Jul 9, 2024
1 parent 913b8b6 commit 23ac2a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package net.laprun.sustainability.power;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -61,6 +63,17 @@ public SensorMetadata(@JsonProperty("metadata") Map<String, ComponentMetadata> c
}
}

@Override
public String toString() {
final var sb = new StringBuilder();
components.values().stream().sorted(Comparator.comparing(ComponentMetadata::index))
.forEach(cm -> sb.append("- ").append(cm).append("\n"));
return "components:\n"
+ sb
+ "documentation: " + documentation + "\n"
+ "totalComponents: " + Arrays.toString(totalComponents);
}

/**
* Determines whether a component with the specified name is known for this sensor
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void initMetadata(InputStream inputStream) {
"macOS powermetrics derived information, see https://firefox-source-docs.mozilla.org/performance/powermetrics.html",
cpu.getTotalComponents());
cpu.setMetadata(metadata);
Log.info("Detected metadata: " + metadata);
Log.info("Detected metadata:\n" + metadata);
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand Down

0 comments on commit 23ac2a6

Please sign in to comment.