CORDA-2725: Set DJVM CLI logging threshold to "TRACE". (#4867)

- Configure root logging level programmatically.
- Support DEBUG logging level.
This commit is contained in:
Chris Rankin 2019-03-09 18:26:21 +00:00 committed by Tommy Lillehagen
parent 061db8b1a1
commit 9648b16ff1
3 changed files with 21 additions and 2 deletions

View File

@ -8,6 +8,8 @@ import net.corda.djvm.references.ClassReference
import net.corda.djvm.references.EntityReference
import net.corda.djvm.references.MemberReference
import net.corda.djvm.rewiring.SandboxClassLoadingException
import org.apache.logging.log4j.Level
import org.apache.logging.log4j.core.config.Configurator
import picocli.CommandLine
import picocli.CommandLine.Help.Ansi
import picocli.CommandLine.Option
@ -102,6 +104,7 @@ abstract class CommandBase : Callable<Boolean> {
printError("Error: Cannot set verbose and quiet modes at the same time")
return false
}
configureLogging()
return try {
handleCommand()
} catch (exception: Throwable) {
@ -110,6 +113,17 @@ abstract class CommandBase : Callable<Boolean> {
}
}
private fun configureLogging() {
val logLevel = when(level) {
Severity.ERROR -> Level.ERROR
Severity.WARNING -> Level.WARN
Severity.INFORMATIONAL -> Level.INFO
Severity.DEBUG -> Level.DEBUG
Severity.TRACE -> Level.TRACE
}
Configurator.setRootLevel(logLevel)
}
protected fun printException(exception: Throwable) = when (exception) {
is SandboxClassLoadingException -> {
printMessages(exception.messages, exception.classOrigins)

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="info">
<ThresholdFilter level="info"/>
<ThresholdFilter level="trace"/>
<Appenders>
<!-- Will generate up to 10 log files for a given day. During every rollover it will delete
those that are older than 60 days, but keep the most recent 10 GB -->

View File

@ -12,7 +12,12 @@ enum class Severity(val shortName: String, val precedence: Int, val color: Strin
/**
* Trace message.
*/
TRACE("TRACE", 3, null),
TRACE("TRACE", 4, null),
/**
* Debug message.
*/
DEBUG("DEBUG", 3, null),
/**
* Informational message.