diff options
author | Duarte Meneses <duarte.meneses@sonarsource.com> | 2016-03-08 14:23:02 +0100 |
---|---|---|
committer | Duarte Meneses <duarte.meneses@sonarsource.com> | 2016-03-08 16:48:14 +0100 |
commit | c6cb6e144fe0238bdb181fc2713374a4bab7a9dc (patch) | |
tree | cbc7f833a59885c3a4e6430e79d4ed83cfc8f311 /src/main/java/org/sonarsource/scanner/cli/Main.java | |
parent | 6dcf5f86801005d810d895e881d21b7181e4473e (diff) | |
download | sonar-scanner-cli-c6cb6e144fe0238bdb181fc2713374a4bab7a9dc.tar.gz sonar-scanner-cli-c6cb6e144fe0238bdb181fc2713374a4bab7a9dc.zip |
SONARUNNER-153 sonar.verbose and sonar.log.level do not work
Diffstat (limited to 'src/main/java/org/sonarsource/scanner/cli/Main.java')
-rw-r--r-- | src/main/java/org/sonarsource/scanner/cli/Main.java | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/main/java/org/sonarsource/scanner/cli/Main.java b/src/main/java/org/sonarsource/scanner/cli/Main.java index a4b2526..548caa3 100644 --- a/src/main/java/org/sonarsource/scanner/cli/Main.java +++ b/src/main/java/org/sonarsource/scanner/cli/Main.java @@ -68,9 +68,10 @@ public class Main { void execute() { Stats stats = new Stats(logger).start(); - + try { Properties p = conf.properties(); + configureLogging(p); init(p); runner.start(); @@ -81,7 +82,7 @@ public class Main { } } catch (Exception e) { displayExecutionResult(stats, "FAILURE"); - showError("Error during SonarQube Scanner execution", e, cli.isDisplayStackTrace()); + showError("Error during SonarQube Scanner execution", e, cli.isDisplayStackTrace() || cli.isDebugEnabled()); shutdown.exit(Exit.ERROR); } @@ -96,7 +97,7 @@ public class Main { runAnalysis(stats, p); } catch (Exception e) { displayExecutionResult(stats, "FAILURE"); - showError("Error during SonarQube Scanner execution", e, cli.isDisplayStackTrace()); + showError("Error during SonarQube Scanner execution", e, cli.isDisplayStackTrace() || cli.isDebugEnabled()); } } while (waitForUser()); } @@ -114,6 +115,19 @@ public class Main { runner = runnerFactory.create(p); } + private void configureLogging(Properties props) throws IOException { + if("true".equals(props.getProperty("sonar.verbose")) + || "DEBUG".equalsIgnoreCase(props.getProperty("sonar.log.level")) + || "TRACE".equalsIgnoreCase(props.getProperty("sonar.log.level")) ) { + logger.setDebugEnabled(true); + logger.setDisplayStackTrace(true); + } + + if(cli.isDisplayStackTrace()) { + logger.setDisplayStackTrace(true); + } + } + private void runAnalysis(Stats stats, Properties p) { runner.runAnalysis(p); displayExecutionResult(stats, "SUCCESS"); @@ -154,7 +168,7 @@ public class Main { private void showError(String message, Throwable e, boolean showStackTrace) { if (showStackTrace) { logger.error(message, e); - if (!cli.isDebugMode()) { + if (!cli.isDebugEnabled()) { logger.error(""); suggestDebugMode(); } @@ -172,7 +186,7 @@ public class Main { } logger.error(""); logger.error("To see the full stack trace of the errors, re-run SonarQube Scanner with the -e switch."); - if (!cli.isDebugMode()) { + if (!cli.isDebugEnabled()) { suggestDebugMode(); } } |