From 54a9fc303511af70b47c4bc720bded44ebd53c0b Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Thu, 28 Jun 2012 10:44:23 +0200 Subject: [PATCH] #2279 - making logging of RLCEs configurable --- akka-remote/src/main/resources/reference.conf | 3 +++ .../src/main/scala/akka/remote/RemoteSettings.scala | 1 + .../src/main/scala/akka/remote/RemoteTransport.scala | 7 ++++++- .../main/scala/akka/remote/netty/NettyRemoteSupport.scala | 2 ++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/akka-remote/src/main/resources/reference.conf b/akka-remote/src/main/resources/reference.conf index a8d2cb2680..f365d5ce19 100644 --- a/akka-remote/src/main/resources/reference.conf +++ b/akka-remote/src/main/resources/reference.conf @@ -71,6 +71,9 @@ akka { # If this is "on", Akka will log all outbound messages at DEBUG level, if off then they are not logged log-sent-messages = off + # If this is "on", Akka will log all RemoteLifeCycleEvents at the level defined for each, if off then they are not logged + log-remote-lifecycle-events = off + # Each property is annotated with (I) or (O) or (I&O), where I stands for “inbound” and O for “outbound” connections. # The NettyRemoteTransport always starts the server role to allow inbound connections, and it starts # active client connections whenever sending to a destination which is not yet connected; if configured diff --git a/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala b/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala index 951c007fbc..88a7003309 100644 --- a/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala +++ b/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala @@ -14,4 +14,5 @@ class RemoteSettings(val config: Config, val systemName: String) { val LogSend: Boolean = getBoolean("akka.remote.log-sent-messages") val RemoteSystemDaemonAckTimeout: Duration = Duration(getMilliseconds("akka.remote.remote-daemon-ack-timeout"), MILLISECONDS) val UntrustedMode: Boolean = getBoolean("akka.remote.untrusted-mode") + val LogRemoteLifeCycleEvents: Boolean = getBoolean("akka.remote.log-remote-lifecycle-events") } diff --git a/akka-remote/src/main/scala/akka/remote/RemoteTransport.scala b/akka-remote/src/main/scala/akka/remote/RemoteTransport.scala index c48cc430f2..f91c5b03d0 100644 --- a/akka-remote/src/main/scala/akka/remote/RemoteTransport.scala +++ b/akka-remote/src/main/scala/akka/remote/RemoteTransport.scala @@ -202,7 +202,7 @@ abstract class RemoteTransport(val system: ExtendedActorSystem, val provider: Re */ def notifyListeners(message: RemoteLifeCycleEvent): Unit = { system.eventStream.publish(message) - system.log.log(message.logLevel, "{}", message) + if (logRemoteLifeCycleEvents) log.log(message.logLevel, "{}", message) } /** @@ -220,6 +220,11 @@ abstract class RemoteTransport(val system: ExtendedActorSystem, val provider: Re */ protected def useUntrustedMode: Boolean + /** + * When this method returns true, RemoteLifeCycleEvents will be logged as well as be put onto the eventStream. + */ + protected def logRemoteLifeCycleEvents: Boolean + /** * Returns a newly created AkkaRemoteProtocol with the given message payload. */ diff --git a/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala b/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala index 9c6e4c85f2..5e3c989fd5 100644 --- a/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala +++ b/akka-remote/src/main/scala/akka/remote/netty/NettyRemoteSupport.scala @@ -128,6 +128,8 @@ private[akka] class NettyRemoteTransport(_system: ExtendedActorSystem, _provider override protected def useUntrustedMode = remoteSettings.UntrustedMode + override protected def logRemoteLifeCycleEvents = remoteSettings.LogRemoteLifeCycleEvents + val server: NettyRemoteServer = try createServer() catch { case NonFatal(ex) ⇒ shutdown(); throw ex } /**