Skip to content

Commit 45a67d3

Browse files
Fix issue that counters are printed to wrong log.
1 parent b5fba2e commit 45a67d3

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateDiagnostics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ public int maxInvocationCount() {
740740
@RestrictHeapAccess(access = RestrictHeapAccess.Access.NO_ALLOCATION, reason = "Must not allocate while printing diagnostics.")
741741
public void printDiagnostics(Log log, ErrorContext context, int maxDiagnosticLevel, int invocationCount) {
742742
log.string("Counters:").indent(true);
743-
Counter.logValues();
743+
Counter.logValues(log);
744744
log.indent(false);
745745
}
746746
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/Counter.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
* option is enabled. Counters are {@link Group grouped} for printing.
5151
*
5252
* Currently there is no shutdown hook in Substrate VM that is invoked automatically, so
53-
* {@link Counter#logValues()} needs to be called manually at the end of the application to print
53+
* {@link Counter#logValues} needs to be called manually at the end of the application to print
5454
* counter values.
5555
*
5656
* Use this class in the following way:
@@ -112,27 +112,27 @@ public void reset() {
112112
/**
113113
* Prints all counters of this group to the {@link Log}.
114114
*/
115-
public void logValues() {
115+
public void logValues(Log log) {
116116
long total = 0;
117117
int maxNameLen = 0;
118118
for (Counter counter : counters) {
119119
total += counter.getValue();
120120
maxNameLen = Math.max(counter.name.length(), maxNameLen);
121121
}
122122

123-
Log.log().string("=== ").string(name).string(" ===").newline();
123+
log.string("=== ").string(name).string(" ===").newline();
124124
for (Counter counter : counters) {
125125
long counterValue = counter.getValue();
126126
long percent = total == 0 ? 0 : counterValue * 100 / total;
127-
Log.log().string(" ").string(counter.name, maxNameLen, Log.RIGHT_ALIGN).string(":");
128-
Log.log().unsigned(counterValue, 10, Log.RIGHT_ALIGN).unsigned(percent, 5, Log.RIGHT_ALIGN).string("%");
127+
log.string(" ").string(counter.name, maxNameLen, Log.RIGHT_ALIGN).string(":");
128+
log.unsigned(counterValue, 10, Log.RIGHT_ALIGN).unsigned(percent, 5, Log.RIGHT_ALIGN).string("%");
129129
if (!counter.description.isEmpty()) {
130-
Log.log().string(" // ").string(counter.description);
130+
log.string(" // ").string(counter.description);
131131
}
132-
Log.log().newline();
132+
log.newline();
133133
}
134-
Log.log().string(" ").string("TOTAL", maxNameLen, Log.RIGHT_ALIGN).string(":");
135-
Log.log().unsigned(total, 10, Log.RIGHT_ALIGN).newline();
134+
log.string(" ").string("TOTAL", maxNameLen, Log.RIGHT_ALIGN).string(":");
135+
log.unsigned(total, 10, Log.RIGHT_ALIGN).newline();
136136
}
137137
}
138138

@@ -212,9 +212,9 @@ public void reset() {
212212
/**
213213
* Prints all counters of all enabled groups to the {@link Log}.
214214
*/
215-
public static void logValues() {
215+
public static void logValues(Log log) {
216216
for (Counter.Group group : ImageSingletons.lookup(CounterSupport.class).enabledGroups) {
217-
group.logValues();
217+
group.logValues(log);
218218
}
219219
}
220220
}

0 commit comments

Comments
 (0)