Commit 54a23f99 authored by Dave Syer's avatar Dave Syer

Make -q and -v do something more sensible

-q switches off all logging and the banner, -v switches logging to debug,
running with neither will be info.

Fixes gh-1108
parent 93c0f6fb
...@@ -67,8 +67,17 @@ public class SpringApplicationRunner { ...@@ -67,8 +67,17 @@ public class SpringApplicationRunner {
this.sources = sources.clone(); this.sources = sources.clone();
this.args = args.clone(); this.args = args.clone();
this.compiler = new GroovyCompiler(configuration); this.compiler = new GroovyCompiler(configuration);
if (configuration.getLogLevel().intValue() <= Level.FINE.intValue()) { int level = configuration.getLogLevel().intValue();
if (level <= Level.FINER.intValue()) {
System.setProperty("groovy.grape.report.downloads", "true"); System.setProperty("groovy.grape.report.downloads", "true");
System.setProperty("trace", "true");
}
else if (level <= Level.FINE.intValue()) {
System.setProperty("debug", "true");
}
else if (level == Level.OFF.intValue()) {
System.setProperty("spring.main.showBanner", "false");
System.setProperty("logging.level.ROOT", "OFF");
} }
} }
......
...@@ -206,13 +206,17 @@ public class LoggingApplicationListener implements SmartApplicationListener { ...@@ -206,13 +206,17 @@ public class LoggingApplicationListener implements SmartApplicationListener {
Map<String, Object> levels = new RelaxedPropertyResolver(environment) Map<String, Object> levels = new RelaxedPropertyResolver(environment)
.getSubProperties("logging.level."); .getSubProperties("logging.level.");
for (Entry<String, Object> entry : levels.entrySet()) { for (Entry<String, Object> entry : levels.entrySet()) {
String name = entry.getKey();
try { try {
LogLevel level = LogLevel.valueOf(entry.getValue().toString()); LogLevel level = LogLevel.valueOf(entry.getValue().toString());
system.setLogLevel(entry.getKey(), level); if (name.equalsIgnoreCase("root")) {
name = null;
}
system.setLogLevel(name, level);
} }
catch (RuntimeException e) { catch (RuntimeException e) {
this.logger.error("Cannot set level: " + entry.getValue() + " for '" this.logger.error("Cannot set level: " + entry.getValue() + " for '"
+ entry.getKey() + "'"); + name + "'");
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment