Skip to content

Commit cb3987a

Browse files
committed
[GR-67833] Improve -XX:FlightRecorderLogging error message for unknown tag set
PullRequest: graal/21567
2 parents 4f61e16 + d34fd1f commit cb3987a

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

docs/reference-manual/native-image/JFR.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ You can configure the logging for the JFR system with a separate flag `-XX:Fligh
5959
The usage is: `-XX:FlightRecorderLogging=[tag1[+tag2...][*][=level][,...]]`.
6060
For example:
6161
```shell
62-
-XX:FlightRecorderLogging=jfr,system=debug
62+
-XX:FlightRecorderLogging=jfr+system=debug
6363
-XX:FlightRecorderLogging=all=trace
6464
-XX:FlightRecorderLogging=jfr*=error
6565
```

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/logging/JfrLogConfiguration.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,27 @@ private static void setLogTagSetLevels(JfrLogSelection[] selections) {
9292
private static void verifySelections(JfrLogSelection[] selections) {
9393
for (JfrLogSelection selection : selections) {
9494
if (!selection.matchesATagSet) {
95+
// prepare suggestions
96+
StringBuilder logTagSuggestions = new StringBuilder();
97+
for (Set<JfrLogTag> valid : JfrLogConfiguration.LOG_TAG_SETS.values()) {
98+
if (valid.containsAll(selection.tags)) {
99+
boolean first = true;
100+
for (JfrLogTag jfrLogTag : valid) {
101+
if (!first) {
102+
logTagSuggestions.append("+");
103+
}
104+
logTagSuggestions.append(jfrLogTag.toString().toLowerCase(Locale.ROOT));
105+
first = false;
106+
}
107+
if (!logTagSuggestions.isEmpty()) {
108+
logTagSuggestions.append(" ");
109+
}
110+
}
111+
}
112+
95113
throw new IllegalArgumentException("No tag set matches tag combination " +
96-
selection.tags.toString().toLowerCase(Locale.ROOT) + (selection.wildcard ? "*" : "") + " for FlightRecorderLogging");
114+
selection.tags.toString().toLowerCase(Locale.ROOT) + (selection.wildcard ? "*" : "") + " for FlightRecorderLogging" +
115+
(logTagSuggestions.isEmpty() ? "" : ". Did you mean any of the following? " + logTagSuggestions));
97116
}
98117
}
99118
}

0 commit comments

Comments
 (0)