From 409b4e2a425d2348d0e0ccb5ea1e972a189a39e7 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Wed, 22 Aug 2018 00:01:45 +0200 Subject: [PATCH] Minor: make the trace logging for the RPC server a bit more helpful. --- .../corda/node/services/messaging/RPCServer.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt b/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt index eefe70f323..9fcb4a83f0 100644 --- a/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt +++ b/node/src/main/kotlin/net/corda/node/services/messaging/RPCServer.kt @@ -305,7 +305,18 @@ class RPCServer( private fun clientArtemisMessageHandler(artemisMessage: ClientMessage) { lifeCycle.requireState(State.STARTED) val clientToServer = RPCApi.ClientToServer.fromClientMessage(artemisMessage) - log.debug { "-> RPC -> $clientToServer" } + if (log.isDebugEnabled) { + when (clientToServer) { + is RPCApi.ClientToServer.RpcRequest -> { + val username = artemisMessage.getStringProperty("_AMQ_VALIDATED_USER") ?: "(unknown)" + // Don't print the whole object because most of the data is useless. + log.debug { "-> RPC by $username -> ${clientToServer.methodName}" } + } + is RPCApi.ClientToServer.ObservablesClosed -> { + log.debug { "-> RPC observable closed -> $clientToServer"} + } + } + } try { when (clientToServer) { is RPCApi.ClientToServer.RpcRequest -> { @@ -349,12 +360,15 @@ class RPCServer( return Try.on { try { CURRENT_RPC_CONTEXT.set(context) - log.debug { "Calling $methodName" } + log.trace { "Calling $methodName" } val method = methodTable[methodName] ?: throw RPCException("Received RPC for unknown method $methodName - possible client/server version skew?") method.invoke(ops, *arguments.toTypedArray()) } catch (e: InvocationTargetException) { throw e.cause ?: RPCException("Caught InvocationTargetException without cause") + } catch (e: Exception) { + log.warn("Caught exception attempting to invoke RPC $methodName", e) + throw e } finally { CURRENT_RPC_CONTEXT.remove() }