private void configureLogging() { if (loggingConfig != null) { loggingConfig.setProperties(globalProperties); LoggingConfigurator.apply(loggingConfig); } }
private static Appender<ILoggingEvent> createAppender(LogOutput target) { LogCallbackAppender appender = new LogCallbackAppender(target); appender.setName(CUSTOM_APPENDER_NAME); appender.start(); return appender; } }
public LoggingConfiguration setProperties(Map<String, String> properties) { setVerbose(properties); return this; }
public void setUp(boolean verbose) { Batch.Builder builder = Batch.builder() .setEnableLoggingConfiguration(true) .addComponents( loader, new EnvironmentInformation("mediumTest", "1.0")); if (verbose) { builder.setBootstrapProperties(Collections.singletonMap("sonar.verbose", "true")); } batch = builder.build(); }
@Test public void shouldDisableLoggingConfiguration() { Batch batch = Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .addComponent("fake") .setEnableLoggingConfiguration(false) .build(); assertNull(batch.getLoggingConfiguration()); }
private Batch newBatch() { return Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .addComponent("fake") .build(); }
@Test(expected = IllegalStateException.class) public void shouldFailIfNullComponents() { Batch.builder() .setEnvironment(new EnvironmentInformation("Gradle", "1.0")) .setComponents(null) .build(); }
public LoggingConfiguration(@Nullable EnvironmentInformation environment) { setVerbose(false); if (environment != null && "maven".equalsIgnoreCase(environment.getKey())) { setFormat(FORMAT_MAVEN); } else { setFormat(FORMAT_DEFAULT); } }
public static void apply(LoggingConfiguration conf, File logbackFile) { Logback.configure(logbackFile, conf.getSubstitutionVariables()); if (conf.getLogOutput() != null) { setCustomRootAppender(conf); } }
@Override protected void append(ILoggingEvent event) { if (event.getThrowableProxy() == null) { target.log(event.getFormattedMessage(), translate(event.getLevel())); } else { ExtendedThrowableProxyConverter throwableConverter = new ExtendedThrowableProxyConverter(); throwableConverter.start(); target.log(event.getFormattedMessage() + "\n" + throwableConverter.convert(event), translate(event.getLevel())); throwableConverter.stop(); } }
public LoggingConfiguration setVerbose(boolean verbose) { return setRootLevel(verbose ? LEVEL_ROOT_VERBOSE : LEVEL_ROOT_DEFAULT); }
@Before public void setUp() { out = new ByteArrayOutputStream(); conf = new LoggingConfiguration(); listener = new SimpleLogListener(); }
@Test public void testChangeTarget() { listener = mock(LogOutput.class); appender.setTarget(listener); testLevelTranslation(); } }
public LoggingConfiguration setRootLevel(String level) { return addSubstitutionVariable(PROPERTY_ROOT_LOGGER_LEVEL, level); }
public static Builder builder() { return new Builder(); }
public LogCallbackAppender(LogOutput target) { setTarget(target); }
public static void apply(LoggingConfiguration conf) { apply(conf, "/org/sonar/batch/bootstrapper/logback.xml"); }
public synchronized Batch execute() { return doExecute(this.globalProperties, this.components); }
@Test public void loggingConfigurationShouldBeEnabledByDefault() { assertNotNull(newBatch().getLoggingConfiguration()); }
public static void apply(LoggingConfiguration conf, String classloaderPath) { Logback.configure(classloaderPath, conf.getSubstitutionVariables()); // if not set, keep default behavior (configured to stdout through the file in classpath) if (conf.getLogOutput() != null) { setCustomRootAppender(conf); } }