Skip to content

Commit af0fd0e

Browse files
stelfrichctrueden
authored andcommitted
ImageJ2Options: add log level selection
1 parent f614a57 commit af0fd0e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/main/java/net/imagej/legacy/ImageJ2Options.java

+31
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ public class ImageJ2Options extends OptionsPlugin implements Interactive {
8484
callback = "run")
8585
private boolean sciJavaIO = false;
8686

87+
@Parameter(
88+
label = "SciJava log level",
89+
description = "<html>Log level for SciJava",
90+
callback = "setLogLevel",
91+
choices = {"ERROR", "WARN", "INFO", "DEBUG", "TRACE"})
92+
private String logLevel = "WARN";
93+
8794
@Parameter(label = "What is ImageJ2?", persist = false, callback = "help")
8895
private Button help;
8996

@@ -201,4 +208,28 @@ private void help() {
201208
System.err.println(message);
202209
}
203210
}
211+
212+
@SuppressWarnings("unused")
213+
private void setLogLevel() {
214+
log.setLevel(parseLogLevel(logLevel));
215+
}
216+
217+
/**
218+
* Parses a log level from a {@code String}.
219+
*
220+
* @param level
221+
* @return the {@code int} associated with the level
222+
*/
223+
private int parseLogLevel(final String level) {
224+
switch (level) {
225+
case "NONE": return LogService.NONE;
226+
case "ERROR": return LogService.ERROR;
227+
case "WARN": return LogService.WARN;
228+
case "INFO": return LogService.INFO;
229+
case "DEBUG": return LogService.DEBUG;
230+
case "TRACE": return LogService.TRACE;
231+
}
232+
233+
return LogService.WARN;
234+
}
204235
}

0 commit comments

Comments
 (0)