|
50 | 50 | * option is enabled. Counters are {@link Group grouped} for printing. |
51 | 51 | * |
52 | 52 | * 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 |
54 | 54 | * counter values. |
55 | 55 | * |
56 | 56 | * Use this class in the following way: |
@@ -112,27 +112,27 @@ public void reset() { |
112 | 112 | /** |
113 | 113 | * Prints all counters of this group to the {@link Log}. |
114 | 114 | */ |
115 | | - public void logValues() { |
| 115 | + public void logValues(Log log) { |
116 | 116 | long total = 0; |
117 | 117 | int maxNameLen = 0; |
118 | 118 | for (Counter counter : counters) { |
119 | 119 | total += counter.getValue(); |
120 | 120 | maxNameLen = Math.max(counter.name.length(), maxNameLen); |
121 | 121 | } |
122 | 122 |
|
123 | | - Log.log().string("=== ").string(name).string(" ===").newline(); |
| 123 | + log.string("=== ").string(name).string(" ===").newline(); |
124 | 124 | for (Counter counter : counters) { |
125 | 125 | long counterValue = counter.getValue(); |
126 | 126 | 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("%"); |
129 | 129 | if (!counter.description.isEmpty()) { |
130 | | - Log.log().string(" // ").string(counter.description); |
| 130 | + log.string(" // ").string(counter.description); |
131 | 131 | } |
132 | | - Log.log().newline(); |
| 132 | + log.newline(); |
133 | 133 | } |
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(); |
136 | 136 | } |
137 | 137 | } |
138 | 138 |
|
@@ -212,9 +212,9 @@ public void reset() { |
212 | 212 | /** |
213 | 213 | * Prints all counters of all enabled groups to the {@link Log}. |
214 | 214 | */ |
215 | | - public static void logValues() { |
| 215 | + public static void logValues(Log log) { |
216 | 216 | for (Counter.Group group : ImageSingletons.lookup(CounterSupport.class).enabledGroups) { |
217 | | - group.logValues(); |
| 217 | + group.logValues(log); |
218 | 218 | } |
219 | 219 | } |
220 | 220 | } |
|
0 commit comments