From 6a2e50b730df86e9b2edef1e2157ef1513539c68 Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Wed, 6 Jun 2018 13:19:18 +0100 Subject: [PATCH] Blobinspector: trace level logging with --verbose (#3313) --- tools/blobinspector/build.gradle | 3 ++- .../src/main/kotlin/net/corda/blobinspector/Main.kt | 9 ++++++++- tools/blobinspector/src/main/resources/log4j2.xml | 13 +++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 tools/blobinspector/src/main/resources/log4j2.xml diff --git a/tools/blobinspector/build.gradle b/tools/blobinspector/build.gradle index 5d49461034..df0ca18fa6 100644 --- a/tools/blobinspector/build.gradle +++ b/tools/blobinspector/build.gradle @@ -4,7 +4,8 @@ apply plugin: 'kotlin' dependencies { compile project(':client:jackson') compile 'info.picocli:picocli:3.0.0' - compile "org.slf4j:slf4j-nop:$slf4j_version" + compile "org.slf4j:jul-to-slf4j:$slf4j_version" + compile "org.apache.logging.log4j:log4j-slf4j-impl:$log4j_version" compile "com.jcabi:jcabi-manifests:$jcabi_manifests_version" testCompile project(':test-utils') diff --git a/tools/blobinspector/src/main/kotlin/net/corda/blobinspector/Main.kt b/tools/blobinspector/src/main/kotlin/net/corda/blobinspector/Main.kt index e2bde0639e..c65b02c6f8 100644 --- a/tools/blobinspector/src/main/kotlin/net/corda/blobinspector/Main.kt +++ b/tools/blobinspector/src/main/kotlin/net/corda/blobinspector/Main.kt @@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.JsonFactory import com.fasterxml.jackson.dataformat.yaml.YAMLFactory import com.jcabi.manifests.Manifests import net.corda.client.jackson.JacksonSupport +import net.corda.core.internal.isRegularFile import net.corda.core.internal.rootMessage import net.corda.core.serialization.SerializationContext import net.corda.core.serialization.deserialize @@ -63,6 +64,8 @@ class Main : Runnable { var verbose: Boolean = false override fun run() { + System.setProperty("logLevel", if (verbose) "trace" else "off") + val bytes = source!!.readBytes().run { require(size > amqpMagic.size) { "Insufficient bytes for AMQP blob" } sequence() @@ -74,6 +77,8 @@ class Main : Runnable { val envelope = DeserializationInput.getEnvelope(bytes) println(envelope.schema) println() + println(envelope.transformsSchema) + println() } initialiseSerialization() @@ -112,7 +117,9 @@ private class SourceConverter : ITypeConverter { return try { URL(value) } catch (e: MalformedURLException) { - Paths.get(value).toUri().toURL() + val path = Paths.get(value) + require(path.isRegularFile()) { "$path is not a file" } + path.toUri().toURL() } } } diff --git a/tools/blobinspector/src/main/resources/log4j2.xml b/tools/blobinspector/src/main/resources/log4j2.xml new file mode 100644 index 0000000000..a9885efca9 --- /dev/null +++ b/tools/blobinspector/src/main/resources/log4j2.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file