/** * Check that log message is not formatted, i.e. has no log level and timestamp. */ private void assertMsgClean(String msg) { // FP: [JOURNAL_FLUSHER] WARNING Journal flush operation took 2,093ms last 8 cycles average is 262ms if (msg.contains("[JOURNAL_FLUSHER]")) { return; } for (LogOutput.Level l : LogOutput.Level.values()) { assertThat(msg).doesNotContain(l.toString()); } Matcher matcher = simpleTimePattern.matcher(msg); assertThat(matcher.find()).isFalse(); }
@Override public void log(String formattedMessage, Level level) { logOutput.log(formattedMessage, org.sonar.runner.batch.LogOutput.Level.valueOf(level.name())); }
@Override public Batch createBatch(Map<String, String> properties, final org.sonarsource.scanner.api.internal.batch.LogOutput logOutput) { EnvironmentInformation env = new EnvironmentInformation(properties.get(SCANNER_APP_KEY), properties.get(SCANNER_APP_VERSION_KEY)); return Batch.builder() .setEnvironment(env) .setGlobalProperties(properties) .setLogOutput((formattedMessage, level) -> logOutput.log(formattedMessage, LogOutput.Level.valueOf(level.name()))) .build(); } }
@Override public Batch createBatch(Map<String, String> properties, final org.sonarsource.scanner.api.internal.batch.LogOutput logOutput) { EnvironmentInformation env = new EnvironmentInformation(properties.get(SCANNER_APP_KEY), properties.get(SCANNER_APP_VERSION_KEY)); return Batch.builder() .setEnvironment(env) .setGlobalProperties(properties) .setLogOutput((formattedMessage, level) -> logOutput.log(formattedMessage, LogOutput.Level.valueOf(level.name()))) .build(); } }
@Override public synchronized void log(String formattedMessage, Level level) { recordedByLevel.put(level.toString(), formattedMessage); recorded.add(formattedMessage); asString.append(formattedMessage).append("\n"); }