Fix log level setup during startup (#439)

Signed-off-by: Lucas Saldanha <lucas.saldanha@consensys.net>
pull/440/head
Lucas Saldanha 5 years ago committed by GitHub
parent d1fa4b78a4
commit 634404c626
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      besu/src/main/java/org/hyperledger/besu/cli/BesuCommand.java
  2. 15
      besu/src/test/java/org/hyperledger/besu/cli/BesuCommandTest.java

@ -629,9 +629,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
@Option(
names = {"--logging", "-l"},
paramLabel = "<LOG VERBOSITY LEVEL>",
description =
"Logging verbosity levels: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL (default: ${DEFAULT-VALUE})")
private final Level logLevel = LogManager.getRootLogger().getLevel();
description = "Logging verbosity levels: OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, ALL")
private final Level logLevel = null;
@Option(
names = {"--miner-enabled"},
@ -2022,7 +2021,8 @@ public class BesuCommand implements DefaultCommandValues, Runnable {
return new BesuExceptionHandler(this::getLogLevel);
}
private Level getLogLevel() {
@VisibleForTesting
Level getLogLevel() {
return logLevel;
}
}

@ -87,6 +87,7 @@ import com.google.common.collect.Lists;
import com.google.common.io.Resources;
import io.vertx.core.json.JsonObject;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.logging.log4j.Level;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.toml.Toml;
import org.apache.tuweni.toml.TomlParseResult;
@ -3484,4 +3485,18 @@ public class BesuCommandTest extends CommandTestAbstract {
.startsWith("Contents of privacy-public-key-file invalid");
assertThat(commandErrorOutput.toString()).contains("Illegal base64 character");
}
@Test
public void logLevelHasNullAsDefaultValue() {
final TestBesuCommand command = parseCommand();
assertThat(command.getLogLevel()).isNull();
}
@Test
public void logLevelIsSetByLoggingOption() {
final TestBesuCommand command = parseCommand("--logging", "WARN");
assertThat(command.getLogLevel()).isEqualTo(Level.WARN);
}
}

Loading…
Cancel
Save