Search in sources :

Example 1 with LoggingConfig

use of tech.pegasys.teku.infrastructure.logging.LoggingConfig in project teku by ConsenSys.

the class BeaconNodeCommand method startLogging.

private void startLogging() {
    LoggingConfig loggingConfig = buildLoggingConfig(dataOptions.getDataPath(), LOG_FILE_PREFIX);
    loggingConfigurator.startLogging(loggingConfig);
    // jupnp logs a lot of context to level WARN, and it is quite verbose.
    LoggingConfigurator.setAllLevelsSilently("org.jupnp", Level.ERROR);
}
Also used : LoggingConfig(tech.pegasys.teku.infrastructure.logging.LoggingConfig)

Example 2 with LoggingConfig

use of tech.pegasys.teku.infrastructure.logging.LoggingConfig in project teku by ConsenSys.

the class LoggingOptionsTest method loggingOptions_shouldReadFromConfigurationFile.

@Test
public void loggingOptions_shouldReadFromConfigurationFile() {
    final LoggingConfig loggingConfig = getLoggingConfigFromFile("loggingOptions_config.yaml");
    assertThat(loggingConfig.getDestination()).isEqualTo(LoggingDestination.FILE);
    assertThat(loggingConfig.isColorEnabled()).isFalse();
    assertThat(loggingConfig.isIncludeEventsEnabled()).isFalse();
    assertThat(loggingConfig.getLogFile()).isEqualTo(VersionProvider.defaultStoragePath() + SLASH + "logs" + SLASH + "a.log");
    assertThat(loggingConfig.getLogFileNamePattern()).isEqualTo(VersionProvider.defaultStoragePath() + SLASH + "logs" + SLASH + "a%d.log");
}
Also used : LoggingConfig(tech.pegasys.teku.infrastructure.logging.LoggingConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) AbstractBeaconNodeCommandTest(tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest)

Example 3 with LoggingConfig

use of tech.pegasys.teku.infrastructure.logging.LoggingConfig in project teku by ConsenSys.

the class LoggingOptionsTest method shouldSetLogFileRelativeToSetDataDirectory.

@Test
public void shouldSetLogFileRelativeToSetDataDirectory() {
    final String[] args = { "--data-path", OSUtils.toOSPath("/yo") };
    final LoggingConfig config = getLoggingConfigurationFromArguments(args);
    assertThat(config.getLogFile()).isEqualTo(OSUtils.toOSPath("/yo/logs/teku.log"));
}
Also used : LoggingConfig(tech.pegasys.teku.infrastructure.logging.LoggingConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) AbstractBeaconNodeCommandTest(tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest)

Example 4 with LoggingConfig

use of tech.pegasys.teku.infrastructure.logging.LoggingConfig in project teku by ConsenSys.

the class LoggingOptionsTest method shouldSetLogPatternToDefaultDataDirectory.

@Test
public void shouldSetLogPatternToDefaultDataDirectory() {
    final String[] args = { "--data-path", OSUtils.toOSPath("/my/path") };
    final LoggingConfig config = getLoggingConfigurationFromArguments(args);
    assertThat(config.getLogFileNamePattern()).isEqualTo(OSUtils.toOSPath("/my/path/logs/" + LOG_PATTERN));
}
Also used : LoggingConfig(tech.pegasys.teku.infrastructure.logging.LoggingConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) AbstractBeaconNodeCommandTest(tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest)

Example 5 with LoggingConfig

use of tech.pegasys.teku.infrastructure.logging.LoggingConfig in project teku by ConsenSys.

the class LoggingOptionsTest method shouldSetLogPatternOnWithoutPath.

@Test
public void shouldSetLogPatternOnWithoutPath() {
    final String[] args = { "--log-file-name-pattern", "%d.log" };
    final String expectedLogPatternPath = StringUtils.joinWith(System.getProperty("file.separator"), VersionProvider.defaultStoragePath(), "logs", "%d.log");
    final LoggingConfig config = getLoggingConfigurationFromArguments(args);
    assertThat(config.getLogFileNamePattern()).isEqualTo(expectedLogPatternPath);
}
Also used : LoggingConfig(tech.pegasys.teku.infrastructure.logging.LoggingConfig) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) AbstractBeaconNodeCommandTest(tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest)

Aggregations

LoggingConfig (tech.pegasys.teku.infrastructure.logging.LoggingConfig)18 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 Test (org.junit.jupiter.api.Test)13 AbstractBeaconNodeCommandTest (tech.pegasys.teku.cli.AbstractBeaconNodeCommandTest)13 ValueSource (org.junit.jupiter.params.provider.ValueSource)2