diff --git a/akka-actor/src/main/scala/akka/actor/Actor.scala b/akka-actor/src/main/scala/akka/actor/Actor.scala index 8a7b045475..202b48fa36 100644 --- a/akka-actor/src/main/scala/akka/actor/Actor.scala +++ b/akka-actor/src/main/scala/akka/actor/Actor.scala @@ -95,18 +95,18 @@ object Actor extends Logging { val hook = new Runnable { override def run { // Shutdown HawtDispatch GlobalQueue - log.info("Shutting down Hawt Dispatch global queue") + log.slf4j.info("Shutting down Hawt Dispatch global queue") org.fusesource.hawtdispatch.ScalaDispatch.globalQueue.asInstanceOf[org.fusesource.hawtdispatch.internal.GlobalDispatchQueue].shutdown // Clear Thread.subclassAudits - log.info("Clearing subclass audits") + log.slf4j.info("Clearing subclass audits") val tf = classOf[java.lang.Thread].getDeclaredField("subclassAudits") tf.setAccessible(true) val subclassAudits = tf.get(null).asInstanceOf[java.util.Map[_,_]] subclassAudits.synchronized {subclassAudits.clear} // Clear and reset j.u.l.Level.known (due to Configgy) - log.info("Removing Configgy-installed log levels") + log.slf4j.info("Removing Configgy-installed log levels") import java.util.logging.Level val lf = classOf[Level].getDeclaredField("known") lf.setAccessible(true) @@ -351,14 +351,14 @@ trait Actor extends Logging { *
    *   def receive =  {
    *     case Ping =>
-   *       log.info("got a 'Ping' message")
+   *       log.slf4j.info("got a 'Ping' message")
    *       self.reply("pong")
    *
    *     case OneWay =>
-   *       log.info("got a 'OneWay' message")
+   *       log.slf4j.info("got a 'OneWay' message")
    *
    *     case unknown =>
-   *       log.warning("unknown message [%s], ignoring", unknown)
+   *       log.slf4j.warn("unknown message [{}], ignoring", unknown)
    * }
    * 
*/ diff --git a/akka-actor/src/main/scala/akka/actor/ActorRef.scala b/akka-actor/src/main/scala/akka/actor/ActorRef.scala index ddc26313d5..8d0bbed6af 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRef.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRef.scala @@ -578,7 +578,7 @@ trait ActorRef extends ActorRefShared with java.lang.Comparable[ActorRef] { scal protected[akka] def checkReceiveTimeout = { cancelReceiveTimeout if (receiveTimeout.isDefined && dispatcher.mailboxSize(this) <= 0) { //Only reschedule if desired and there are currently no more messages to be processed - log.debug("Scheduling timeout for %s", this) + log.slf4j.debug("Scheduling timeout for {}", this) _futureTimeout = Some(Scheduler.scheduleOnce(this, ReceiveTimeout, receiveTimeout.get, TimeUnit.MILLISECONDS)) } } @@ -587,7 +587,7 @@ trait ActorRef extends ActorRefShared with java.lang.Comparable[ActorRef] { scal if (_futureTimeout.isDefined) { _futureTimeout.get.cancel(true) _futureTimeout = None - log.debug("Timeout canceled for %s", this) + log.slf4j.debug("Timeout canceled for {}", this) } } } @@ -764,7 +764,7 @@ class LocalActorRef private[akka] ( "Actor can only have one supervisor [" + actorRef + "], e.g. link(actor) fails") linkedActors.put(actorRef.uuid, actorRef) actorRef.supervisor = Some(this) - Actor.log.debug("Linking actor [%s] to actor [%s]", actorRef, this) + Actor.log.slf4j.debug("Linking actor [{}] to actor [{}]", actorRef, this) } /** @@ -777,7 +777,7 @@ class LocalActorRef private[akka] ( "Actor [" + actorRef + "] is not a linked actor, can't unlink") linkedActors.remove(actorRef.uuid) actorRef.supervisor = None - Actor.log.debug("Unlinking actor [%s] from actor [%s]", actorRef, this) + Actor.log.slf4j.debug("Unlinking actor [{}] from actor [{}]", actorRef, this) } /** @@ -911,14 +911,15 @@ class LocalActorRef private[akka] ( * Callback for the dispatcher. This is the single entry point to the user Actor implementation. */ protected[akka] def invoke(messageHandle: MessageInvocation): Unit = guard.withGuard { - if (isShutdown) Actor.log.warning("Actor [%s] is shut down,\n\tignoring message [%s]", toString, messageHandle) + if (isShutdown) Actor.log.slf4j.warn("Actor [{}] is shut down,\n\tignoring message [{}]", toString, messageHandle) else { currentMessage = messageHandle try { dispatch(messageHandle) } catch { case e => - Actor.log.error(e, "Could not invoke actor [%s]", this) + Actor.log.slf4j.error("Could not invoke actor [{}]", this) + Actor.log.slf4j.error("Problem", e) throw e } finally { currentMessage = null //TODO: Don't reset this, we might want to resend the message @@ -972,9 +973,9 @@ class LocalActorRef private[akka] ( protected[akka] def restart(reason: Throwable, maxNrOfRetries: Option[Int], withinTimeRange: Option[Int]) { def performRestart { - Actor.log.info("Restarting actor [%s] configured as PERMANENT.", id) + Actor.log.slf4j.info("Restarting actor [{}] configured as PERMANENT.", id) val failedActor = actorInstance.get - Actor.log.debug("Invoking 'preRestart' for failed actor instance [%s].", id) + Actor.log.slf4j.debug("Invoking 'preRestart' for failed actor instance [{}].", id) failedActor.preRestart(reason) val freshActor = newActor setActorSelfFields(failedActor,null) //Only null out the references if we could instantiate the new actor @@ -984,24 +985,24 @@ class LocalActorRef private[akka] ( case p: Proxyable => p.swapProxiedActor(freshActor) case _ => } - Actor.log.debug("Invoking 'postRestart' for new actor instance [%s].", id) + Actor.log.slf4j.debug("Invoking 'postRestart' for new actor instance [{}].", id) freshActor.postRestart(reason) } def tooManyRestarts { - Actor.log.warning( - "Maximum number of restarts [%s] within time range [%s] reached." + - "\n\tWill *not* restart actor [%s] anymore." + + Actor.log.slf4j.warn( + "Maximum number of restarts [{}] within time range [{}] reached." + + "\n\tWill *not* restart actor [{}] anymore." + "\n\tLast exception causing restart was" + - "\n\t[%s].", - maxNrOfRetries, withinTimeRange, this, reason) + "\n\t[{}].", + Array(maxNrOfRetries, withinTimeRange, this, reason)) _supervisor.foreach { sup => // can supervisor handle the notification? val notification = MaximumNumberOfRestartsWithinTimeRangeReached(this, maxNrOfRetries, withinTimeRange, reason) if (sup.isDefinedAt(notification)) notifySupervisorWithMessage(notification) - else Actor.log.warning( + else Actor.log.slf4j.warn( "No message handler defined for system message [MaximumNumberOfRestartsWithinTimeRangeReached]" + - "\n\tCan't send the message to the supervisor [%s].", sup) + "\n\tCan't send the message to the supervisor [{}].", sup) } stop @@ -1024,7 +1025,7 @@ class LocalActorRef private[akka] ( case e => false //An error or exception here should trigger a retry } - Actor.log.debug("Restart: %s for [%s].", success, id) + Actor.log.slf4j.debug("Restart: {} for [{}].", success, id) if (success) { _status = ActorRefInternals.RUNNING @@ -1079,7 +1080,7 @@ class LocalActorRef private[akka] ( } private def dispatch[T](messageHandle: MessageInvocation) = { - Actor.log.trace("Invoking actor with message: %s\n", messageHandle) + Actor.log.slf4j.trace("Invoking actor with message: {}\n", messageHandle) val message = messageHandle.message //serializeMessage(messageHandle.message) try { @@ -1095,14 +1096,14 @@ class LocalActorRef private[akka] ( } private def shutDownTemporaryActor(temporaryActor: ActorRef) { - Actor.log.info("Actor [%s] configured as TEMPORARY and will not be restarted.", temporaryActor.id) + Actor.log.slf4j.info("Actor [{}] configured as TEMPORARY and will not be restarted.", temporaryActor.id) temporaryActor.stop linkedActors.remove(temporaryActor.uuid) // remove the temporary actor // if last temporary actor is gone, then unlink me from supervisor if (linkedActors.isEmpty) { - Actor.log.info( + Actor.log.slf4j.info( "All linked actors have died permanently (they were all configured as TEMPORARY)" + - "\n\tshutting down and unlinking supervisor actor as well [%s].", + "\n\tshutting down and unlinking supervisor actor as well [{}].", temporaryActor.id) notifySupervisorWithMessage(UnlinkAndStop(this)) } @@ -1111,7 +1112,8 @@ class LocalActorRef private[akka] ( } private def handleExceptionInDispatch(reason: Throwable, message: Any) = { - Actor.log.error(reason, "Exception when invoking \n\tactor [%s] \n\twith message [%s]", this, message) + Actor.log.slf4j.error("Exception when invoking \n\tactor [{}] \n\twith message [{}]", this, message) + Actor.log.slf4j.error("Problem", reason) //Prevent any further messages to be processed until the actor has been restarted dispatcher.suspend(this) @@ -1168,7 +1170,7 @@ class LocalActorRef private[akka] ( private def initializeActorInstance = { actor.preStart // run actor preStart - Actor.log.trace("[%s] has started", toString) + Actor.log.slf4j.trace("[{}] has started", toString) ActorRegistry.register(this) } diff --git a/akka-actor/src/main/scala/akka/actor/ActorRegistry.scala b/akka-actor/src/main/scala/akka/actor/ActorRegistry.scala index 3476304a67..68fdb50d85 100644 --- a/akka-actor/src/main/scala/akka/actor/ActorRegistry.scala +++ b/akka-actor/src/main/scala/akka/actor/ActorRegistry.scala @@ -254,7 +254,7 @@ object ActorRegistry extends ListenerManagement { * Shuts down and unregisters all actors in the system. */ def shutdownAll() { - log.info("Shutting down all actors in the system...") + log.slf4j.info("Shutting down all actors in the system...") if (TypedActorModule.isEnabled) { val elements = actorsByUUID.elements while (elements.hasMoreElements) { @@ -266,7 +266,7 @@ object ActorRegistry extends ListenerManagement { } else foreach(_.stop) actorsByUUID.clear actorsById.clear - log.info("All actors have been shut down and unregistered from ActorRegistry") + log.slf4j.info("All actors have been shut down and unregistered from ActorRegistry") } /** diff --git a/akka-actor/src/main/scala/akka/actor/BootableActorLoaderService.scala b/akka-actor/src/main/scala/akka/actor/BootableActorLoaderService.scala index d0deed1287..3d3f06a2c5 100644 --- a/akka-actor/src/main/scala/akka/actor/BootableActorLoaderService.scala +++ b/akka-actor/src/main/scala/akka/actor/BootableActorLoaderService.scala @@ -26,7 +26,7 @@ trait BootableActorLoaderService extends Bootable with Logging { val DEPLOY = HOME.getOrElse(throwNoAkkaHomeException) + "/deploy" val DEPLOY_DIR = new File(DEPLOY) if (!DEPLOY_DIR.exists) { - log.error("Could not find a deploy directory at [%s]", DEPLOY) + log.slf4j.error("Could not find a deploy directory at [{}]", DEPLOY) System.exit(-1) } val filesToDeploy = DEPLOY_DIR.listFiles.toArray.toList @@ -42,8 +42,8 @@ trait BootableActorLoaderService extends Bootable with Logging { } } val toDeploy = filesToDeploy.map(_.toURI.toURL) - log.info("Deploying applications from [%s]: [%s]", DEPLOY, toDeploy) - log.debug("Loading dependencies [%s]", dependencyJars) + log.slf4j.info("Deploying applications from [{}]: [{}]", DEPLOY, toDeploy) + log.slf4j.debug("Loading dependencies [{}]", dependencyJars) val allJars = toDeploy ::: dependencyJars new URLClassLoader(allJars.toArray,Thread.currentThread.getContextClassLoader) @@ -51,12 +51,12 @@ trait BootableActorLoaderService extends Bootable with Logging { } abstract override def onLoad = { - applicationLoader.foreach(_ => log.info("Creating /deploy class-loader")) + applicationLoader.foreach(_ => log.slf4j.info("Creating /deploy class-loader")) super.onLoad for (loader <- applicationLoader; clazz <- BOOT_CLASSES) { - log.info("Loading boot class [%s]", clazz) + log.slf4j.info("Loading boot class [{}]", clazz) loader.loadClass(clazz).newInstance } } diff --git a/akka-actor/src/main/scala/akka/actor/FSM.scala b/akka-actor/src/main/scala/akka/actor/FSM.scala index c801309e19..678a9ec1cc 100644 --- a/akka-actor/src/main/scala/akka/actor/FSM.scala +++ b/akka-actor/src/main/scala/akka/actor/FSM.scala @@ -72,17 +72,17 @@ trait FSM[S, D] { private var handleEvent: StateFunction = { case Event(value, stateData) => - log.warning("Event %s not handled in state %s, staying at current state", value, currentState.stateName) + log.slf4j.warn("Event {} not handled in state {}, staying at current state", value, currentState.stateName) stay } private var terminateEvent: PartialFunction[Reason, Unit] = { - case failure@Failure(_) => log.error("Stopping because of a %s", failure) - case reason => log.info("Stopping because of reason: %s", reason) + case failure@Failure(_) => log.slf4j.error("Stopping because of a {}", failure) + case reason => log.slf4j.info("Stopping because of reason: {}", reason) } private var transitionEvent: PartialFunction[Transition, Unit] = { - case Transition(from, to) => log.debug("Transitioning from state %s to %s", from, to) + case Transition(from, to) => log.slf4j.debug("Transitioning from state {} to {}", from, to) } override final protected def receive: Receive = { @@ -141,7 +141,7 @@ trait FSM[S, D] { def replying(replyValue:Any): State = { self.sender match { case Some(sender) => sender ! replyValue - case None => log.error("Unable to send reply value %s, no sender reference to reply to", replyValue) + case None => log.slf4j.error("Unable to send reply value {}, no sender reference to reply to", replyValue) } this } @@ -166,4 +166,4 @@ trait FSM[S, D] { case class TimeoutMarker(generation: Long) case class Transition(from: S, to: S) -} \ No newline at end of file +} diff --git a/akka-actor/src/main/scala/akka/actor/Scheduler.scala b/akka-actor/src/main/scala/akka/actor/Scheduler.scala index ae7f2193ee..2096710088 100644 --- a/akka-actor/src/main/scala/akka/actor/Scheduler.scala +++ b/akka-actor/src/main/scala/akka/actor/Scheduler.scala @@ -29,15 +29,15 @@ object Scheduler extends Logging { @volatile private var service = Executors.newSingleThreadScheduledExecutor(SchedulerThreadFactory) - log.info("Starting up Scheduler") + log.slf4j.info("Starting up Scheduler") /** * Schedules to send the specified message to the receiver after initialDelay and then repeated after delay */ def schedule(receiver: ActorRef, message: AnyRef, initialDelay: Long, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = { - log.trace( - "Schedule scheduled event\n\tevent = [%s]\n\treceiver = [%s]\n\tinitialDelay = [%s]\n\tdelay = [%s]\n\ttimeUnit = [%s]", - message, receiver, initialDelay, delay, timeUnit) + log.slf4j.trace( + "Schedule scheduled event\n\tevent = [{}]\n\treceiver = [{}]\n\tinitialDelay = [{}]\n\tdelay = [{}]\n\ttimeUnit = [{}]", + Array(message, receiver, initialDelay, delay, timeUnit)) try { service.scheduleAtFixedRate( new Runnable { def run = receiver ! message }, @@ -59,9 +59,9 @@ object Scheduler extends Logging { * avoid blocking operations since this is executed in the schedulers thread */ def schedule(runnable: Runnable, initialDelay: Long, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = { - log.trace( - "Schedule scheduled event\n\trunnable = [%s]\n\tinitialDelay = [%s]\n\tdelay = [%s]\n\ttimeUnit = [%s]", - runnable, initialDelay, delay, timeUnit) + log.slf4j.trace( + "Schedule scheduled event\n\trunnable = [{}]\n\tinitialDelay = [{}]\n\tdelay = [{}]\n\ttimeUnit = [{}]", + Array(runnable, initialDelay, delay, timeUnit)) try { service.scheduleAtFixedRate(runnable,initialDelay, delay, timeUnit).asInstanceOf[ScheduledFuture[AnyRef]] @@ -74,9 +74,9 @@ object Scheduler extends Logging { * Schedules to send the specified message to the receiver after delay */ def scheduleOnce(receiver: ActorRef, message: AnyRef, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = { - log.trace( - "Schedule one-time event\n\tevent = [%s]\n\treceiver = [%s]\n\tdelay = [%s]\n\ttimeUnit = [%s]", - message, receiver, delay, timeUnit) + log.slf4j.trace( + "Schedule one-time event\n\tevent = [{}]\n\treceiver = [{}]\n\tdelay = [{}]\n\ttimeUnit = [{}]", + Array(message, receiver, delay, timeUnit)) try { service.schedule( new Runnable { def run = receiver ! message }, @@ -98,9 +98,9 @@ object Scheduler extends Logging { * avoid blocking operations since the runnable is executed in the schedulers thread */ def scheduleOnce(runnable: Runnable, delay: Long, timeUnit: TimeUnit): ScheduledFuture[AnyRef] = { - log.trace( - "Schedule one-time event\n\trunnable = [%s]\n\tdelay = [%s]\n\ttimeUnit = [%s]", - runnable, delay, timeUnit) + log.slf4j.trace( + "Schedule one-time event\n\trunnable = [{}]\n\tdelay = [{}]\n\ttimeUnit = [{}]", + Array(runnable, delay, timeUnit)) try { service.schedule(runnable,delay, timeUnit).asInstanceOf[ScheduledFuture[AnyRef]] } catch { @@ -109,12 +109,12 @@ object Scheduler extends Logging { } def shutdown: Unit = synchronized { - log.info("Shutting down Scheduler") + log.slf4j.info("Shutting down Scheduler") service.shutdown } def restart: Unit = synchronized { - log.info("Restarting Scheduler") + log.slf4j.info("Restarting Scheduler") shutdown service = Executors.newSingleThreadScheduledExecutor(SchedulerThreadFactory) } diff --git a/akka-actor/src/main/scala/akka/actor/Supervisor.scala b/akka-actor/src/main/scala/akka/actor/Supervisor.scala index daa0bac6c9..351cdecf89 100644 --- a/akka-actor/src/main/scala/akka/actor/Supervisor.scala +++ b/akka-actor/src/main/scala/akka/actor/Supervisor.scala @@ -168,7 +168,7 @@ final class SupervisorActor private[akka] (handler: FaultHandlingStrategy) exten // FIXME add a way to respond to MaximumNumberOfRestartsWithinTimeRangeReached in declaratively configured Supervisor case MaximumNumberOfRestartsWithinTimeRangeReached( victim, maxNrOfRetries, withinTimeRange, lastExceptionCausingRestart) => - Actor.log.warning( + Actor.log.slf4j.warn( "Declaratively configured supervisor received a [MaximumNumberOfRestartsWithinTimeRangeReached] notification," + "\n\tbut there is currently no way of handling it in a declaratively configured supervisor." + "\n\tIf you want to be able to handle this error condition then you need to create the supervision tree programatically." + diff --git a/akka-actor/src/main/scala/akka/config/Config.scala b/akka-actor/src/main/scala/akka/config/Config.scala index 371e61b640..419d268012 100644 --- a/akka-actor/src/main/scala/akka/config/Config.scala +++ b/akka-actor/src/main/scala/akka/config/Config.scala @@ -6,9 +6,6 @@ package akka.config import akka.AkkaException import akka.util.Logging -import akka.actor.{ActorRef, IllegalActorStateException} -import akka.dispatch.CompletableFuture - import net.lag.configgy.{Config => CConfig, Configgy, ParseException} import java.net.InetSocketAddress @@ -17,14 +14,12 @@ import java.lang.reflect.Method class ConfigurationException(message: String) extends AkkaException(message) class ModuleNotAvailableException(message: String) extends AkkaException(message) -object ConfigLogger extends Logging - /** * Loads up the configuration (from the akka.conf file). * * @author Jonas Bonér */ -object Config { +object Config extends Logging { val VERSION = "1.0-SNAPSHOT" val HOME = { @@ -62,7 +57,7 @@ object Config { val configFile = System.getProperty("akka.config", "") try { Configgy.configure(configFile) - ConfigLogger.log.info("Config loaded from -Dakka.config=%s", configFile) + log.slf4j.info("Config loaded from -Dakka.config={}", configFile) } catch { case e: ParseException => throw new ConfigurationException( "Config could not be loaded from -Dakka.config=" + configFile + @@ -73,8 +68,8 @@ object Config { try { val configFile = HOME.getOrElse(throwNoAkkaHomeException) + "/config/" + confName Configgy.configure(configFile) - ConfigLogger.log.info( - "AKKA_HOME is defined as [%s], config loaded from [%s].", + log.slf4j.info( + "AKKA_HOME is defined as [{}], config loaded from [{}].", HOME.getOrElse(throwNoAkkaHomeException), configFile) } catch { @@ -87,7 +82,7 @@ object Config { } else if (getClass.getClassLoader.getResource(confName) ne null) { try { Configgy.configureFromResource(confName, getClass.getClassLoader) - ConfigLogger.log.info("Config [%s] loaded from the application classpath.",confName) + log.slf4j.info("Config [{}] loaded from the application classpath.",confName) } catch { case e: ParseException => throw new ConfigurationException( "Can't load '" + confName + "' config file from application classpath," + @@ -95,7 +90,7 @@ object Config { } Configgy.config } else { - ConfigLogger.log.warning( + log.slf4j.warn( "\nCan't load '" + confName + "'." + "\nOne of the three ways of locating the '" + confName + "' file needs to be defined:" + "\n\t1. Define the '-Dakka.config=...' system property option." + diff --git a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala index 2673d0af33..1b61195bc6 100644 --- a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenDispatcher.scala @@ -123,12 +123,12 @@ class ExecutorBasedEventDrivenDispatcher( private[akka] def createDurableMailbox(actorRef: ActorRef, mailboxType: DurableMailboxType): AnyRef = createMailbox(mailboxType.mailboxImplClassname, actorRef) - private[akka] def start = log.debug("Starting up %s\n\twith throughput [%d]", toString, throughput) + private[akka] def start = log.slf4j.debug("Starting up {}\n\twith throughput [{}]", this, throughput) private[akka] def shutdown { val old = executorService.getAndSet(config.createLazyExecutorService(threadFactory)) if (old ne null) { - log.debug("Shutting down %s", toString) + log.slf4j.debug("Shutting down {}", this) old.shutdownNow() } } @@ -144,17 +144,17 @@ class ExecutorBasedEventDrivenDispatcher( throw e } } - } else log.warning("%s is shut down,\n\tignoring the rest of the messages in the mailbox of\n\t%s", this, mbox) + } else log.slf4j.warn("{} is shut down,\n\tignoring the rest of the messages in the mailbox of\n\t{}", this, mbox) override val toString = getClass.getSimpleName + "[" + name + "]" def suspend(actorRef: ActorRef) { - log.debug("Suspending %s",actorRef.uuid) + log.slf4j.debug("Suspending {}",actorRef.uuid) getMailbox(actorRef).suspended.switchOn } def resume(actorRef: ActorRef) { - log.debug("Resuming %s",actorRef.uuid) + log.slf4j.debug("Resuming {}",actorRef.uuid) val mbox = getMailbox(actorRef) mbox.suspended.switchOff registerForExecution(mbox) diff --git a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala index 42f3e0f4cf..7ced9f8f0e 100644 --- a/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala +++ b/akka-actor/src/main/scala/akka/dispatch/ExecutorBasedEventDrivenWorkStealingDispatcher.scala @@ -171,12 +171,12 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher( } else false } - private[akka] def start = log.debug("Starting up %s",toString) + private[akka] def start = log.slf4j.debug("Starting up {}",toString) private[akka] def shutdown { val old = executorService.getAndSet(config.createLazyExecutorService(threadFactory)) if (old ne null) { - log.debug("Shutting down %s", toString) + log.slf4j.debug("Shutting down {}", toString) old.shutdownNow() } } @@ -244,7 +244,7 @@ class ExecutorBasedEventDrivenWorkStealingDispatcher( case Some(aType) => if (aType != actorOfId.actor.getClass) throw new IllegalActorStateException(String.format( - "Can't register actor %s in a work stealing dispatcher which already knows actors of type %s", + "Can't register actor {} in a work stealing dispatcher which already knows actors of type {}", actorOfId.actor, aType)) } } diff --git a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala index b766a7a974..f0f2f259d6 100644 --- a/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala +++ b/akka-actor/src/main/scala/akka/dispatch/MessageHandling.scala @@ -135,7 +135,7 @@ trait MessageDispatcher extends MailboxFactory with Logging { ActorRegistry.actorFor(uuid) match { case Some(actor) => actor.stop case None => - log.error("stopAllLinkedActors couldn't find linked actor: " + uuid) + log.slf4j.error("stopAllLinkedActors couldn't find linked actor: " + uuid) } } } diff --git a/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala b/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala index f6e92892d0..fa7f4acf19 100644 --- a/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala +++ b/akka-actor/src/main/scala/akka/dispatch/ThreadPoolBuilder.scala @@ -174,18 +174,18 @@ class MonitorableThread(runnable: Runnable, name: String) setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { def uncaughtException(thread: Thread, cause: Throwable) = - log.error(cause, "UNCAUGHT in thread [%s]", thread.getName) + log.slf4j.error("Thread.UncaughtException", cause) }) override def run = { val debug = MonitorableThread.debugLifecycle - log.debug("Created thread %s", getName) + log.slf4j.debug("Created thread {}", getName) try { MonitorableThread.alive.incrementAndGet super.run } finally { MonitorableThread.alive.decrementAndGet - log.debug("Exiting thread %s", getName) + log.slf4j.debug("Exiting thread {}", getName) } } } @@ -212,7 +212,7 @@ class BoundedExecutorDecorator(val executor: ExecutorService, bound: Int) extend case e: RejectedExecutionException => semaphore.release case e => - log.error(e,"Unexpected exception") + log.slf4j.error("Unexpected exception", e) throw e } } @@ -254,7 +254,7 @@ trait LazyExecutorService extends ExecutorServiceDelegate { def createExecutor: ExecutorService lazy val executor = { - log.info("Lazily initializing ExecutorService for ",this) + log.slf4j.info("Lazily initializing ExecutorService for ",this) createExecutor } } diff --git a/akka-actor/src/main/scala/akka/util/AkkaException.scala b/akka-actor/src/main/scala/akka/util/AkkaException.scala index 3ab80a2512..e006690123 100644 --- a/akka-actor/src/main/scala/akka/util/AkkaException.scala +++ b/akka-actor/src/main/scala/akka/util/AkkaException.scala @@ -36,7 +36,7 @@ import java.net.{InetAddress, UnknownHostException} } private lazy val _log = { - AkkaException.log.error(toString) + AkkaException.log.slf4j.error(toString) () } diff --git a/akka-actor/src/main/scala/akka/util/Crypt.scala b/akka-actor/src/main/scala/akka/util/Crypt.scala index bccb291be5..c85646987e 100644 --- a/akka-actor/src/main/scala/akka/util/Crypt.scala +++ b/akka-actor/src/main/scala/akka/util/Crypt.scala @@ -24,7 +24,7 @@ object Crypt extends Logging { def sha1(bytes: Array[Byte]): String = digest(bytes, MessageDigest.getInstance("SHA1")) def generateSecureCookie: String = { - log.info("Generating secure cookie...") + log.slf4j.info("Generating secure cookie...") val bytes = Array.fill(32)(0.byteValue) random.nextBytes(bytes) sha1(bytes) diff --git a/akka-actor/src/main/scala/akka/util/Helpers.scala b/akka-actor/src/main/scala/akka/util/Helpers.scala index 25180a68d7..09f6865984 100644 --- a/akka-actor/src/main/scala/akka/util/Helpers.scala +++ b/akka-actor/src/main/scala/akka/util/Helpers.scala @@ -42,7 +42,8 @@ object Helpers extends Logging { narrow(o) } catch { case e: ClassCastException => - log.warning(e, "Cannot narrow %s to expected type %s!", o, implicitly[Manifest[T]].erasure.getName) + log.slf4j.warn("Cannot narrow {} to expected type {}!", o, implicitly[Manifest[T]].erasure.getName) + log.slf4j.trace("narrowSilently", e) None } diff --git a/akka-actor/src/main/scala/akka/util/ListenerManagement.scala b/akka-actor/src/main/scala/akka/util/ListenerManagement.scala index 9166680873..f372fac18c 100644 --- a/akka-actor/src/main/scala/akka/util/ListenerManagement.scala +++ b/akka-actor/src/main/scala/akka/util/ListenerManagement.scala @@ -57,7 +57,7 @@ trait ListenerManagement extends Logging { while (iterator.hasNext) { val listener = iterator.next if (listener.isRunning) listener ! msg - else log.warning("Can't notify [%s] since it is not running.", listener) + else log.slf4j.warn("Can't notify [{}] since it is not running.", listener) } } } @@ -70,7 +70,7 @@ trait ListenerManagement extends Logging { while (iterator.hasNext) { val listener = iterator.next if (listener.isRunning) f(listener) - else log.warning("Can't notify [%s] since it is not running.", listener) + else log.slf4j.warn("Can't notify [{}] since it is not running.", listener) } } } diff --git a/akka-actor/src/main/scala/akka/util/Logging.scala b/akka-actor/src/main/scala/akka/util/Logging.scala index 02ef6f3136..f349386d42 100644 --- a/akka-actor/src/main/scala/akka/util/Logging.scala +++ b/akka-actor/src/main/scala/akka/util/Logging.scala @@ -6,11 +6,6 @@ package akka.util import org.slf4j.{Logger => SLFLogger,LoggerFactory => SLFLoggerFactory} -import java.io.StringWriter -import java.io.PrintWriter -import java.net.InetAddress -import java.net.UnknownHostException - /** * Base trait for all classes that wants to be able use the logging infrastructure. * @@ -33,110 +28,115 @@ trait Logging { * * The logger uses String.format: * http://download-llnw.oracle.com/javase/6/docs/api/java/lang/String.html#format(java.lang.String,%20java.lang.Object...) + * + * If you want to use underlying slf4j Logger, do: + * log.slf4j.info("My foo is {}","alive") + * log.slf4j.error("My foo is broken",new Exception()) */ -class Logger(val logger: SLFLogger) { - def name = logger.getName +class Logger(val slf4j: SLFLogger) { + final def name = logger.getName + final def logger = slf4j - def trace_? = logger.isTraceEnabled - def debug_? = logger.isDebugEnabled - def info_? = logger.isInfoEnabled - def warning_? = logger.isWarnEnabled - def error_? = logger.isErrorEnabled + final def trace_? = logger.isTraceEnabled + final def debug_? = logger.isDebugEnabled + final def info_? = logger.isInfoEnabled + final def warning_? = logger.isWarnEnabled + final def error_? = logger.isErrorEnabled //Trace - def trace(t: Throwable, fmt: => String, arg: Any, argN: Any*) { + final def trace(t: Throwable, fmt: => String, arg: Any, argN: Any*) { trace(t,message(fmt,arg,argN:_*)) } - def trace(t: Throwable, msg: => String) { + final def trace(t: Throwable, msg: => String) { if (trace_?) logger.trace(msg,t) } - def trace(fmt: => String, arg: Any, argN: Any*) { + final def trace(fmt: => String, arg: Any, argN: Any*) { trace(message(fmt,arg,argN:_*)) } - def trace(msg: => String) { + final def trace(msg: => String) { if (trace_?) logger trace msg } //Debug - def debug(t: Throwable, fmt: => String, arg: Any, argN: Any*) { + final def debug(t: Throwable, fmt: => String, arg: Any, argN: Any*) { debug(t,message(fmt,arg,argN:_*)) } - def debug(t: Throwable, msg: => String) { + final def debug(t: Throwable, msg: => String) { if (debug_?) logger.debug(msg,t) } - def debug(fmt: => String, arg: Any, argN: Any*) { + final def debug(fmt: => String, arg: Any, argN: Any*) { debug(message(fmt,arg,argN:_*)) } - def debug(msg: => String) { + final def debug(msg: => String) { if (debug_?) logger debug msg } //Info - def info(t: Throwable, fmt: => String, arg: Any, argN: Any*) { + final def info(t: Throwable, fmt: => String, arg: Any, argN: Any*) { info(t,message(fmt,arg,argN:_*)) } - def info(t: Throwable, msg: => String) { + final def info(t: Throwable, msg: => String) { if (info_?) logger.info(msg,t) } - def info(fmt: => String, arg: Any, argN: Any*) { + final def info(fmt: => String, arg: Any, argN: Any*) { info(message(fmt,arg,argN:_*)) } - def info(msg: => String) { + final def info(msg: => String) { if (info_?) logger info msg } //Warning - def warning(t: Throwable, fmt: => String, arg: Any, argN: Any*) { + final def warning(t: Throwable, fmt: => String, arg: Any, argN: Any*) { warning(t,message(fmt,arg,argN:_*)) } - def warn(t: Throwable, fmt: => String, arg: Any, argN: Any*) = warning(t, fmt, arg, argN) + final def warn(t: Throwable, fmt: => String, arg: Any, argN: Any*) = warning(t, fmt, arg, argN) - def warning(t: Throwable, msg: => String) { + final def warning(t: Throwable, msg: => String) { if (warning_?) logger.warn(msg,t) } - def warn(t: Throwable, msg: => String) = warning(t, msg) + final def warn(t: Throwable, msg: => String) = warning(t, msg) - def warning(fmt: => String, arg: Any, argN: Any*) { + final def warning(fmt: => String, arg: Any, argN: Any*) { warning(message(fmt,arg,argN:_*)) } - def warn(fmt: => String, arg: Any, argN: Any*) = warning(fmt, arg, argN:_*) + final def warn(fmt: => String, arg: Any, argN: Any*) = warning(fmt, arg, argN:_*) - def warning(msg: => String) { + final def warning(msg: => String) { if (warning_?) logger warn msg } - def warn(msg: => String) = warning(msg) + final def warn(msg: => String) = warning(msg) //Error - def error(t: Throwable, fmt: => String, arg: Any, argN: Any*) { + final def error(t: Throwable, fmt: => String, arg: Any, argN: Any*) { error(t,message(fmt,arg,argN:_*)) } - def error(t: Throwable, msg: => String) { + final def error(t: Throwable, msg: => String) { if (error_?) logger.error(msg,t) } - def error(fmt: => String, arg: Any, argN: Any*) { + final def error(fmt: => String, arg: Any, argN: Any*) { error(message(fmt,arg,argN:_*)) } - def error(msg: => String) { + final def error(msg: => String) { if (error_?) logger error msg } - protected def message(fmt: String, arg: Any, argN: Any*) : String = { + protected final def message(fmt: String, arg: Any, argN: Any*) : String = { if ((argN eq null) || argN.isEmpty) fmt.format(arg) else fmt.format((arg +: argN):_*) } diff --git a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala index f359ab9b98..45e1609b79 100644 --- a/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala +++ b/akka-actor/src/main/scala/akka/util/ReflectiveAccess.scala @@ -185,7 +185,7 @@ object ReflectiveAccess extends Logging { Some(ctor.newInstance(args: _*).asInstanceOf[T]) } catch { case e => - log.warning("Could not instantiate class [%s] due to [%s]", clazz.getName, e.getCause) + log.slf4j.warn("Could not instantiate class [{}] due to [{}]", clazz.getName, e.getCause) None } @@ -202,7 +202,7 @@ object ReflectiveAccess extends Logging { Some(ctor.newInstance(args: _*).asInstanceOf[T]) } catch { case e => - log.warning("Could not instantiate class [%s] due to [%s]", fqn, e.getCause) + log.slf4j.warn("Could not instantiate class [{}] due to [{}]", fqn, e.getCause) None } @@ -214,7 +214,7 @@ object ReflectiveAccess extends Logging { Option(instance.get(null).asInstanceOf[T]) } catch { case e: ClassNotFoundException => - log.debug("Could not get object [%s] due to [%s]", fqn, e) + log.slf4j.debug("Could not get object [{}] due to [{}]", fqn, e) None } diff --git a/akka-actor/src/test/scala/akka/actor/actor/FSMActorSpec.scala b/akka-actor/src/test/scala/akka/actor/actor/FSMActorSpec.scala index dd8de44bea..bc9c7e739c 100644 --- a/akka-actor/src/test/scala/akka/actor/actor/FSMActorSpec.scala +++ b/akka-actor/src/test/scala/akka/actor/actor/FSMActorSpec.scala @@ -40,7 +40,7 @@ object FSMActorSpec { goto(Open) using CodeState("", code) forMax timeout } case wrong => { - log.error("Wrong code %s", wrong) + log.slf4j.error("Wrong code {}", wrong) stay using CodeState("", code) } } @@ -60,7 +60,7 @@ object FSMActorSpec { whenUnhandled { case Event(_, stateData) => { - log.info("Unhandled") + log.slf4j.info("Unhandled") unhandledLatch.open stay } @@ -71,12 +71,12 @@ object FSMActorSpec { } private def doLock() { - log.info("Locked") + log.slf4j.info("Locked") lockedLatch.open } private def doUnlock = { - log.info("Unlocked") + log.slf4j.info("Unlocked") unlockedLatch.open } } @@ -122,4 +122,4 @@ class FSMActorSpec extends JUnitSuite { tester ! Bye assert(terminatedLatch.tryAwait(2, TimeUnit.SECONDS)) } -} \ No newline at end of file +} diff --git a/akka-actor/src/test/scala/akka/actor/supervisor/SupervisorSpec.scala b/akka-actor/src/test/scala/akka/actor/supervisor/SupervisorSpec.scala index de06871323..814127752e 100644 --- a/akka-actor/src/test/scala/akka/actor/supervisor/SupervisorSpec.scala +++ b/akka-actor/src/test/scala/akka/actor/supervisor/SupervisorSpec.scala @@ -498,7 +498,7 @@ class SupervisorSpec extends JUnitSuite { val inits = new AtomicInteger(0) val dyingActor = actorOf(new Actor { self.lifeCycle = Permanent - log.debug("Creating dying actor, attempt: " + inits.incrementAndGet) + log.slf4j.debug("Creating dying actor, attempt: " + inits.incrementAndGet) if (!(inits.get % 2 != 0)) throw new IllegalStateException("Don't wanna!") diff --git a/akka-http/src/main/scala/AkkaLoader.scala b/akka-http/src/main/scala/AkkaLoader.scala index 22ff40016c..ec526a7639 100644 --- a/akka-http/src/main/scala/AkkaLoader.scala +++ b/akka-http/src/main/scala/AkkaLoader.scala @@ -24,10 +24,10 @@ class AkkaLoader extends Logging { def boot(withBanner: Boolean, b : Bootable): Unit = synchronized { if (!hasBooted) { if (withBanner) printBanner - log.info("Starting Akka...") + log.slf4j.info("Starting Akka...") b.onLoad Thread.currentThread.setContextClassLoader(getClass.getClassLoader) - log.info("Akka started successfully") + log.slf4j.info("Akka started successfully") hasBooted = true _bundles = Some(b) } @@ -38,40 +38,40 @@ class AkkaLoader extends Logging { */ def shutdown = synchronized { if (hasBooted) { - log.info("Shutting down Akka...") + log.slf4j.info("Shutting down Akka...") _bundles.foreach(_.onUnload) _bundles = None Actor.shutdownHook.run - log.info("Akka succesfully shut down") + log.slf4j.info("Akka succesfully shut down") } } private def printBanner = { - log.info("==================================================") - log.info(" t") - log.info(" t t t") - log.info(" t t tt t") - log.info(" tt t t tt t") - log.info(" t ttttttt t ttt t") - log.info(" t tt ttt t ttt t") - log.info(" t t ttt t ttt t t") - log.info(" tt t ttt ttt ttt t") - log.info(" t t ttt ttt t tt t") - log.info(" t ttt ttt t t") - log.info(" tt ttt ttt t") - log.info(" ttt ttt") - log.info(" tttttttt ttt ttt ttt ttt tttttttt") - log.info(" ttt tt ttt ttt ttt ttt ttt ttt") - log.info(" ttt ttt ttt ttt ttt ttt ttt ttt") - log.info(" ttt ttt ttt ttt ttt tt ttt ttt") - log.info(" tttt ttttttttt tttttttt tttt") - log.info(" ttttttttt ttt ttt ttt ttt ttttttttt") - log.info(" ttt ttt ttt ttt ttt ttt ttt ttt") - log.info(" ttt ttt ttt ttt ttt ttt ttt ttt") - log.info(" ttt tt ttt ttt ttt ttt ttt ttt") - log.info(" tttttttt ttt ttt ttt ttt tttttttt") - log.info("==================================================") - log.info(" Running version %s", Config.VERSION) - log.info("==================================================") + log.slf4j.info("==================================================") + log.slf4j.info(" t") + log.slf4j.info(" t t t") + log.slf4j.info(" t t tt t") + log.slf4j.info(" tt t t tt t") + log.slf4j.info(" t ttttttt t ttt t") + log.slf4j.info(" t tt ttt t ttt t") + log.slf4j.info(" t t ttt t ttt t t") + log.slf4j.info(" tt t ttt ttt ttt t") + log.slf4j.info(" t t ttt ttt t tt t") + log.slf4j.info(" t ttt ttt t t") + log.slf4j.info(" tt ttt ttt t") + log.slf4j.info(" ttt ttt") + log.slf4j.info(" tttttttt ttt ttt ttt ttt tttttttt") + log.slf4j.info(" ttt tt ttt ttt ttt ttt ttt ttt") + log.slf4j.info(" ttt ttt ttt ttt ttt ttt ttt ttt") + log.slf4j.info(" ttt ttt ttt ttt ttt tt ttt ttt") + log.slf4j.info(" tttt ttttttttt tttttttt tttt") + log.slf4j.info(" ttttttttt ttt ttt ttt ttt ttttttttt") + log.slf4j.info(" ttt ttt ttt ttt ttt ttt ttt ttt") + log.slf4j.info(" ttt ttt ttt ttt ttt ttt ttt ttt") + log.slf4j.info(" ttt tt ttt ttt ttt ttt ttt ttt") + log.slf4j.info(" tttttttt ttt ttt ttt ttt tttttttt") + log.slf4j.info("==================================================") + log.slf4j.info(" Running version {}", Config.VERSION) + log.slf4j.info("==================================================") } } diff --git a/akka-http/src/main/scala/EmbeddedAppServer.scala b/akka-http/src/main/scala/EmbeddedAppServer.scala index d46cb775c5..578ac72964 100644 --- a/akka-http/src/main/scala/EmbeddedAppServer.scala +++ b/akka-http/src/main/scala/EmbeddedAppServer.scala @@ -35,7 +35,7 @@ trait EmbeddedAppServer extends Bootable with Logging { abstract override def onLoad = { super.onLoad if (isRestEnabled) { - log.info("Attempting to start Akka HTTP service") + log.slf4j.info("Attempting to start Akka HTTP service") System.setProperty("jetty.port", REST_PORT.toString) System.setProperty("jetty.host", REST_HOSTNAME) @@ -60,14 +60,14 @@ trait EmbeddedAppServer extends Bootable with Logging { s.start() s } - log.info("Akka HTTP service started") + log.slf4j.info("Akka HTTP service started") } } abstract override def onUnload = { super.onUnload server foreach { t => - log.info("Shutting down REST service (Jersey)") + log.slf4j.info("Shutting down REST service (Jersey)") t.stop() } } diff --git a/akka-http/src/main/scala/Mist.scala b/akka-http/src/main/scala/Mist.scala index 8009293ac7..91c528e108 100644 --- a/akka-http/src/main/scala/Mist.scala +++ b/akka-http/src/main/scala/Mist.scala @@ -118,16 +118,16 @@ trait Mist extends Logging { val server = context.getServerInfo val (major, minor) = (context.getMajorVersion, context.getMinorVersion) - log.info("Initializing Akka HTTP on "+server+" with Servlet API "+major+"."+minor) + log.slf4j.info("Initializing Akka HTTP on {} with Servlet API {}.{}",Array(server, major, minor)) _factory = if (major >= 3) { - log.info("Supporting Java asynchronous contexts.") + log.slf4j.info("Supporting Java asynchronous contexts.") Some(Servlet30ContextMethodFactory) } else if (server.toLowerCase startsWith JettyServer) { - log.info("Supporting Jetty asynchronous continuations.") + log.slf4j.info("Supporting Jetty asynchronous continuations.") Some(JettyContinuationMethodFactory) } else { - log.error("No asynchronous request handling can be supported.") + log.slf4j.error("No asynchronous request handling can be supported.") None } } @@ -185,7 +185,7 @@ class AkkaMistFilter extends Filter with Mist { case "POST" => mistify(hreq, hres)(_factory.get.Post) case "PUT" => mistify(hreq, hres)(_factory.get.Put) case "TRACE" => mistify(hreq, hres)(_factory.get.Trace) - case unknown => log.warn("Unknown http method: %s",unknown) + case unknown => log.slf4j.warn("Unknown http method: {}",unknown) } chain.doFilter(req,res) case _ => chain.doFilter(req,res) @@ -270,7 +270,7 @@ trait Endpoint { this: Actor => */ protected def _na(uri: String, req: RequestMethod) = { req.NotFound("No endpoint available for [" + uri + "]") - log.debug("No endpoint available for [" + uri + "]") + log.slf4j.debug("No endpoint available for [{}]", uri) } } @@ -300,7 +300,7 @@ class RootEndpoint extends Actor with Endpoint { def recv: Receive = { case NoneAvailable(uri, req) => _na(uri, req) - case unknown => log.error("Unexpected message sent to root endpoint. [" + unknown + "]") + case unknown => log.slf4j.error("Unexpected message sent to root endpoint. [{}]", unknown) } /** @@ -387,7 +387,7 @@ trait RequestMethod extends Logging case Some(pipe) => { try { if (!suspended) { - log.warning("Attempt to complete an expired connection.") + log.slf4j.warn("Attempt to complete an expired connection.") false } else { @@ -397,13 +397,13 @@ trait RequestMethod extends Logging } } catch { case io => - log.error(io, "Failed to write data to connection on resume - the client probably disconnected") + log.slf4j.error("Failed to write data to connection on resume - the client probably disconnected", io) false } } case None => - log.error("Attempt to complete request with no context.") + log.slf4j.error("Attempt to complete request with no context.") false } @@ -412,7 +412,7 @@ trait RequestMethod extends Logging case Some(pipe) => { try { if (!suspended) { - log.warning("Attempt to complete an expired connection.") + log.slf4j.warn("Attempt to complete an expired connection.") } else { response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Failed to write data to connection on resume") @@ -420,15 +420,15 @@ trait RequestMethod extends Logging } } catch { - case io: IOException => log.error(io, "Request completed with internal error.") + case io: IOException => log.slf4j.error("Request completed with internal error.", io) } finally { - log.error(t, "Request completed with internal error.") + log.slf4j.error("Request completed with internal error.", t) } } case None => - log.error(t, "Attempt to complete request with no context") + log.slf4j.error("Attempt to complete request with no context", t) } } diff --git a/akka-http/src/main/scala/Security.scala b/akka-http/src/main/scala/Security.scala index e9152970fa..bd50b0a1c7 100644 --- a/akka-http/src/main/scala/Security.scala +++ b/akka-http/src/main/scala/Security.scala @@ -91,7 +91,7 @@ class AkkaSecurityFilterFactory extends ResourceFilterFactory with Logging { throw new WebApplicationException(r.asInstanceOf[Response]) case None => throw new WebApplicationException(408) case unknown => { - log.warning("Authenticator replied with unexpected result [%s]", unknown); + log.slf4j.warn("Authenticator replied with unexpected result [{}]", unknown) throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR) } } @@ -258,7 +258,7 @@ trait DigestAuthenticationActor extends AuthenticationActor[DigestCredentials] w val ts = System.currentTimeMillis nonceMap.filter(tuple => (ts - tuple._2) < nonceValidityPeriod) case unknown => - log.error("Don't know what to do with: ", unknown) + log.slf4j.error("Don't know what to do with: ", unknown) } //Schedule the invalidation of nonces @@ -371,7 +371,7 @@ trait SpnegoAuthenticationActor extends AuthenticationActor[SpnegoCredentials] w Some(UserInfo(user, null, rolesFor(user))) } catch { case e: PrivilegedActionException => { - log.error(e, "Action not allowed") + log.slf4j.error("Action not allowed", e) return None } } diff --git a/akka-http/src/main/scala/Servlet30Context.scala b/akka-http/src/main/scala/Servlet30Context.scala index f890ef3e21..be202006e9 100644 --- a/akka-http/src/main/scala/Servlet30Context.scala +++ b/akka-http/src/main/scala/Servlet30Context.scala @@ -36,7 +36,7 @@ trait Servlet30Context extends AsyncListener with akka.util.Logging } catch { case ex: IllegalStateException => - log.info("Cannot update timeout - already returned to container") + log.slf4j.info("Cannot update timeout - already returned to container") false } } @@ -46,8 +46,8 @@ trait Servlet30Context extends AsyncListener with akka.util.Logging // def onComplete(e: AsyncEvent) {} def onError(e: AsyncEvent) = e.getThrowable match { - case null => log.warning("Error occured...") - case t => log.warning(t, "Error occured") + case null => log.slf4j.warn("Error occured...") + case t => log.slf4j.warn("Error occured", t) } def onStartAsync(e: AsyncEvent) {} def onTimeout(e: AsyncEvent) = { diff --git a/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala b/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala index d67c09cd93..a6a4a9c5e7 100644 --- a/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala +++ b/akka-remote/src/main/scala/akka/remote/BootableRemoteActorService.scala @@ -27,18 +27,18 @@ trait BootableRemoteActorService extends Bootable with Logging { abstract override def onLoad = { if (RemoteServer.isRemotingEnabled) { - log.info("Initializing Remote Actors Service...") + log.slf4j.info("Initializing Remote Actors Service...") startRemoteService - log.info("Remote Actors Service initialized") + log.slf4j.info("Remote Actors Service initialized") } super.onLoad } abstract override def onUnload = { - log.info("Shutting down Remote Actors Service") + log.slf4j.info("Shutting down Remote Actors Service") RemoteNode.shutdown if (remoteServerThread.isAlive) remoteServerThread.join(1000) - log.info("Remote Actors Service has been shut down") + log.slf4j.info("Remote Actors Service has been shut down") super.onUnload } } diff --git a/akka-remote/src/main/scala/akka/remote/RemoteClient.scala b/akka-remote/src/main/scala/akka/remote/RemoteClient.scala index e501411f6f..d19d4eeeb4 100644 --- a/akka-remote/src/main/scala/akka/remote/RemoteClient.scala +++ b/akka-remote/src/main/scala/akka/remote/RemoteClient.scala @@ -238,7 +238,7 @@ class RemoteClient private[akka] ( bootstrap.setOption("tcpNoDelay", true) bootstrap.setOption("keepAlive", true) - log.info("Starting remote client connection to [%s:%s]", hostname, port) + log.slf4j.info("Starting remote client connection to [{}:{}]", hostname, port) // Wait until the connection attempt succeeds or fails. connection = bootstrap.connect(remoteAddress) @@ -247,13 +247,14 @@ class RemoteClient private[akka] ( if (!connection.isSuccess) { notifyListeners(RemoteClientError(connection.getCause, this)) - log.error(connection.getCause, "Remote client connection to [%s:%s] has failed", hostname, port) + log.slf4j.error("Remote client connection to [{}:{}] has failed", hostname, port) + log.slf4j.debug("Remote client connection failed", connection.getCause) } notifyListeners(RemoteClientStarted(this)) } def shutdown = runSwitch switchOff { - log.info("Shutting down %s", name) + log.slf4j.info("Shutting down {}", name) notifyListeners(RemoteClientShutdown(this)) timer.stop timer = null @@ -262,7 +263,7 @@ class RemoteClient private[akka] ( bootstrap.releaseExternalResources bootstrap = null connection = null - log.info("%s has been shut down", name) + log.slf4j.info("{} has been shut down", name) } @deprecated("Use addListener instead") @@ -341,7 +342,7 @@ class RemoteClient private[akka] ( } else { val timeLeft = reconnectionTimeWindow - (System.currentTimeMillis - reconnectionTimeWindowStart) if (timeLeft > 0) { - log.info("Will try to reconnect to remote server for another [%s] milliseconds", timeLeft) + log.slf4j.info("Will try to reconnect to remote server for another [{}] milliseconds", timeLeft) true } else false } @@ -406,7 +407,7 @@ class RemoteClientHandler( override def handleUpstream(ctx: ChannelHandlerContext, event: ChannelEvent) = { if (event.isInstanceOf[ChannelStateEvent] && event.asInstanceOf[ChannelStateEvent].getState != ChannelState.INTEREST_OPS) { - log.debug(event.toString) + log.slf4j.debug(event.toString) } super.handleUpstream(ctx, event) } @@ -417,7 +418,7 @@ class RemoteClientHandler( if (result.isInstanceOf[RemoteMessageProtocol]) { val reply = result.asInstanceOf[RemoteMessageProtocol] val replyUuid = uuidFrom(reply.getUuid.getHigh, reply.getUuid.getLow) - log.debug("Remote client received RemoteMessageProtocol[\n%s]".format(reply.toString)) + log.debug("Remote client received RemoteMessageProtocol[\n{}]",reply) val future = futures.get(replyUuid).asInstanceOf[CompletableFuture[Any]] if (reply.hasMessage) { if (future eq null) throw new IllegalActorStateException("Future mapped to UUID " + replyUuid + " does not exist") @@ -445,7 +446,7 @@ class RemoteClientHandler( } catch { case e: Exception => client.notifyListeners(RemoteClientError(e, client)) - log.error("Unexpected exception in remote client handler: %s", e) + log.slf4j.error("Unexpected exception in remote client handler: {}", e) throw e } } @@ -456,12 +457,13 @@ class RemoteClientHandler( def run(timeout: Timeout) = { client.openChannels.remove(event.getChannel) client.isAuthenticated.set(false) - log.debug("Remote client reconnecting to [%s]", remoteAddress) + log.slf4j.debug("Remote client reconnecting to [{}]", remoteAddress) client.connection = bootstrap.connect(remoteAddress) client.connection.awaitUninterruptibly // Wait until the connection attempt succeeds or fails. if (!client.connection.isSuccess) { client.notifyListeners(RemoteClientError(client.connection.getCause, client)) - log.error(client.connection.getCause, "Reconnection to [%s] has failed", remoteAddress) + log.slf4j.error("Reconnection to [{}] has failed", remoteAddress) + log.slf4j.debug("Reconnection failed", client.connection.getCause) } } }, RemoteClient.RECONNECT_DELAY.toMillis, TimeUnit.MILLISECONDS) @@ -471,7 +473,7 @@ class RemoteClientHandler( override def channelConnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = { def connect = { client.notifyListeners(RemoteClientConnected(client)) - log.debug("Remote client connected to [%s]", ctx.getChannel.getRemoteAddress) + log.slf4j.debug("Remote client connected to [{}]", ctx.getChannel.getRemoteAddress) client.resetReconnectionTimeWindow } @@ -488,12 +490,16 @@ class RemoteClientHandler( override def channelDisconnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = { client.notifyListeners(RemoteClientDisconnected(client)) - log.debug("Remote client disconnected from [%s]", ctx.getChannel.getRemoteAddress) + log.slf4j.debug("Remote client disconnected from [{}]", ctx.getChannel.getRemoteAddress) } override def exceptionCaught(ctx: ChannelHandlerContext, event: ExceptionEvent) = { client.notifyListeners(RemoteClientError(event.getCause, client)) - log.error(event.getCause, "Unexpected exception from downstream in remote client") + if (event.getCause ne null) + log.slf4j.error("Unexpected exception from downstream in remote client", event.getCause) + else + log.slf4j.error("Unexpected exception from downstream in remote client: {}", event) + event.getChannel.close } diff --git a/akka-remote/src/main/scala/akka/remote/RemoteServer.scala b/akka-remote/src/main/scala/akka/remote/RemoteServer.scala index a7c23a8d06..71a306f743 100644 --- a/akka-remote/src/main/scala/akka/remote/RemoteServer.scala +++ b/akka-remote/src/main/scala/akka/remote/RemoteServer.scala @@ -233,7 +233,7 @@ class RemoteServer extends Logging with ListenerManagement { try { if (!_isRunning) { address = Address(_hostname,_port) - log.info("Starting remote server at [%s:%s]", hostname, port) + log.slf4j.info("Starting remote server at [{}:{}]", hostname, port) RemoteServer.register(hostname, port, this) val pipelineFactory = new RemoteServerPipelineFactory(name, openChannels, loader, this) @@ -249,7 +249,7 @@ class RemoteServer extends Logging with ListenerManagement { } } catch { case e => - log.error(e, "Could not start up remote server") + log.slf4j.error("Could not start up remote server", e) notifyListeners(RemoteServerError(e, this)) } this @@ -265,7 +265,7 @@ class RemoteServer extends Logging with ListenerManagement { notifyListeners(RemoteServerShutdown(this)) } catch { case e: java.nio.channels.ClosedChannelException => {} - case e => log.warning("Could not close remote server channel in a graceful way") + case e => log.slf4j.warn("Could not close remote server channel in a graceful way") } } } @@ -281,7 +281,7 @@ class RemoteServer extends Logging with ListenerManagement { * @param typedActor typed actor to register */ def registerTypedActor(id: String, typedActor: AnyRef): Unit = synchronized { - log.debug("Registering server side remote typed actor [%s] with id [%s]", typedActor.getClass.getName, id) + log.slf4j.debug("Registering server side remote typed actor [{}] with id [{}]", typedActor.getClass.getName, id) if (id.startsWith(UUID_PREFIX)) registerTypedActor(id.substring(UUID_PREFIX.length), typedActor, typedActorsByUuid) else registerTypedActor(id, typedActor, typedActors) } @@ -297,7 +297,7 @@ class RemoteServer extends Logging with ListenerManagement { * @param typedActor typed actor to register */ def registerTypedPerSessionActor(id: String, factory: => AnyRef): Unit = synchronized { - log.debug("Registering server side typed remote session actor with id [%s]", id) + log.slf4j.debug("Registering server side typed remote session actor with id [{}]", id) registerTypedPerSessionActor(id, () => factory, typedActorsFactories) } @@ -312,7 +312,7 @@ class RemoteServer extends Logging with ListenerManagement { * NOTE: If you use this method to register your remote actor then you must unregister the actor by this ID yourself. */ def register(id: String, actorRef: ActorRef): Unit = synchronized { - log.debug("Registering server side remote actor [%s] with id [%s]", actorRef.actorClass.getName, id) + log.slf4j.debug("Registering server side remote actor [{}] with id [{}]", actorRef.actorClass.getName, id) if (id.startsWith(UUID_PREFIX)) register(id.substring(UUID_PREFIX.length), actorRef, actorsByUuid) else register(id, actorRef, actors) } @@ -323,7 +323,7 @@ class RemoteServer extends Logging with ListenerManagement { * NOTE: If you use this method to register your remote actor then you must unregister the actor by this ID yourself. */ def registerPerSession(id: String, factory: => ActorRef): Unit = synchronized { - log.debug("Registering server side remote session actor with id [%s]", id) + log.slf4j.debug("Registering server side remote session actor with id [{}]", id) registerPerSession(id, () => factory, actorsFactories) } @@ -354,7 +354,7 @@ class RemoteServer extends Logging with ListenerManagement { */ def unregister(actorRef: ActorRef):Unit = synchronized { if (_isRunning) { - log.debug("Unregistering server side remote actor [%s] with id [%s:%s]", actorRef.actorClass.getName, actorRef.id, actorRef.uuid) + log.slf4j.debug("Unregistering server side remote actor [{}] with id [{}:{}]", Array(actorRef.actorClass.getName, actorRef.id, actorRef.uuid)) actors.remove(actorRef.id, actorRef) actorsByUuid.remove(actorRef.uuid, actorRef) } @@ -367,7 +367,7 @@ class RemoteServer extends Logging with ListenerManagement { */ def unregister(id: String):Unit = synchronized { if (_isRunning) { - log.info("Unregistering server side remote actor with id [%s]", id) + log.slf4j.info("Unregistering server side remote actor with id [{}]", id) if (id.startsWith(UUID_PREFIX)) actorsByUuid.remove(id.substring(UUID_PREFIX.length)) else { val actorRef = actors get id @@ -384,7 +384,7 @@ class RemoteServer extends Logging with ListenerManagement { */ def unregisterPerSession(id: String):Unit = { if (_isRunning) { - log.info("Unregistering server side remote session actor with id [%s]", id) + log.slf4j.info("Unregistering server side remote session actor with id [{}]", id) actorsFactories.remove(id) } } @@ -396,7 +396,7 @@ class RemoteServer extends Logging with ListenerManagement { */ def unregisterTypedActor(id: String):Unit = synchronized { if (_isRunning) { - log.info("Unregistering server side remote typed actor with id [%s]", id) + log.slf4j.info("Unregistering server side remote typed actor with id [{}]", id) if (id.startsWith(UUID_PREFIX)) typedActorsByUuid.remove(id.substring(UUID_PREFIX.length)) else typedActors.remove(id) } @@ -506,7 +506,7 @@ class RemoteServerHandler( val clientAddress = getClientAddress(ctx) sessionActors.set(event.getChannel(), new ConcurrentHashMap[String, ActorRef]()) typedSessionActors.set(event.getChannel(), new ConcurrentHashMap[String, AnyRef]()) - log.debug("Remote client [%s] connected to [%s]", clientAddress, server.name) + log.slf4j.debug("Remote client [{}] connected to [{}]", clientAddress, server.name) if (RemoteServer.SECURE) { val sslHandler: SslHandler = ctx.getPipeline.get(classOf[SslHandler]) // Begin handshake. @@ -524,7 +524,7 @@ class RemoteServerHandler( override def channelDisconnected(ctx: ChannelHandlerContext, event: ChannelStateEvent) = { val clientAddress = getClientAddress(ctx) - log.debug("Remote client [%s] disconnected from [%s]", clientAddress, server.name) + log.slf4j.debug("Remote client [{}] disconnected from [{}]", clientAddress, server.name) // stop all session actors val channelActors = sessionActors.remove(event.getChannel) if (channelActors ne null) { @@ -546,13 +546,13 @@ class RemoteServerHandler( override def channelClosed(ctx: ChannelHandlerContext, event: ChannelStateEvent) = { val clientAddress = getClientAddress(ctx) - log.debug("Remote client [%s] channel closed from [%s]", clientAddress, server.name) + log.slf4j.debug("Remote client [{}] channel closed from [{}]", clientAddress, server.name) server.notifyListeners(RemoteServerClientClosed(server, clientAddress)) } override def handleUpstream(ctx: ChannelHandlerContext, event: ChannelEvent) = { if (event.isInstanceOf[ChannelStateEvent] && event.asInstanceOf[ChannelStateEvent].getState != ChannelState.INTEREST_OPS) { - log.debug(event.toString) + log.slf4j.debug(event.toString) } super.handleUpstream(ctx, event) } @@ -568,7 +568,7 @@ class RemoteServerHandler( } override def exceptionCaught(ctx: ChannelHandlerContext, event: ExceptionEvent) = { - log.error(event.getCause, "Unexpected exception from remote downstream") + log.slf4j.error("Unexpected exception from remote downstream", event.getCause) event.getChannel.close server.notifyListeners(RemoteServerError(event.getCause, server)) } @@ -580,7 +580,7 @@ class RemoteServerHandler( } private def handleRemoteMessageProtocol(request: RemoteMessageProtocol, channel: Channel) = { - log.debug("Received RemoteMessageProtocol[\n%s]".format(request.toString)) + log.slf4j.debug("Received RemoteMessageProtocol[\n{}]",request) request.getActorInfo.getActorType match { case SCALA_ACTOR => dispatchToActor(request, channel) case TYPED_ACTOR => dispatchToTypedActor(request, channel) @@ -591,7 +591,7 @@ class RemoteServerHandler( private def dispatchToActor(request: RemoteMessageProtocol, channel: Channel) { val actorInfo = request.getActorInfo - log.debug("Dispatching to remote actor [%s:%s]", actorInfo.getTarget, actorInfo.getUuid) + log.slf4j.debug("Dispatching to remote actor [{}:{}]", actorInfo.getTarget, actorInfo.getUuid) val actorRef = try { @@ -627,7 +627,7 @@ class RemoteServerHandler( val exception = f.exception if (exception.isDefined) { - log.debug("Returning exception from actor invocation [%s]",exception.get) + log.slf4j.debug("Returning exception from actor invocation [{}]",exception.get) try { channel.write(createErrorReplyMessage(exception.get, request, AkkaActorType.ScalaActor)) } catch { @@ -635,7 +635,7 @@ class RemoteServerHandler( } } else if (result.isDefined) { - log.debug("Returning result from actor invocation [%s]".format(result.get)) + log.slf4j.debug("Returning result from actor invocation [{}]",result.get) val messageBuilder = RemoteActorSerialization.createRemoteMessageProtocolBuilder( Some(actorRef), Right(request.getUuid), @@ -667,7 +667,7 @@ class RemoteServerHandler( private def dispatchToTypedActor(request: RemoteMessageProtocol, channel: Channel) = { val actorInfo = request.getActorInfo val typedActorInfo = actorInfo.getTypedActorInfo - log.debug("Dispatching to remote typed actor [%s :: %s]", typedActorInfo.getMethod, typedActorInfo.getInterface) + log.slf4j.debug("Dispatching to remote typed actor [{} :: {}]", typedActorInfo.getMethod, typedActorInfo.getInterface) val typedActor = createTypedActor(actorInfo, channel) val args = MessageSerializer.deserialize(request.getMessage).asInstanceOf[Array[AnyRef]].toList @@ -693,7 +693,7 @@ class RemoteServerHandler( None) if (request.hasSupervisorUuid) messageBuilder.setSupervisorUuid(request.getSupervisorUuid) channel.write(messageBuilder.build) - log.debug("Returning result from remote typed actor invocation [%s]", result) + log.slf4j.debug("Returning result from remote typed actor invocation [{}]", result) } catch { case e: Throwable => server.notifyListeners(RemoteServerError(e, server)) } @@ -730,7 +730,9 @@ class RemoteServerHandler( } private def findSessionActor(id: String, channel: Channel) : ActorRef = { - sessionActors.get(channel).get(id) + val map = sessionActors.get(channel) + if (map ne null) map.get(id) + else null } private def findTypedActorById(id: String) : AnyRef = { @@ -742,7 +744,9 @@ class RemoteServerHandler( } private def findTypedSessionActor(id: String, channel: Channel) : AnyRef = { - typedSessionActors.get(channel).get(id) + val map = typedSessionActors.get(channel) + if (map ne null) map.get(id) + else null } private def findTypedActorByUuid(uuid: String) : AnyRef = { @@ -798,7 +802,7 @@ class RemoteServerHandler( if (RemoteServer.UNTRUSTED_MODE) throw new SecurityException( "Remote server is operating is untrusted mode, can not create remote actors on behalf of the remote client") - log.info("Creating a new remote actor [%s:%s]", name, uuid) + log.slf4j.info("Creating a new remote actor [{}:{}]", name, uuid) val clazz = if (applicationLoader.isDefined) applicationLoader.get.loadClass(name) else Class.forName(name) val actorRef = Actor.actorOf(clazz.asInstanceOf[Class[_ <: Actor]]) @@ -810,7 +814,7 @@ class RemoteServerHandler( actorRef } catch { case e => - log.error(e, "Could not create remote actor instance") + log.slf4j.error("Could not create remote actor instance", e) server.notifyListeners(RemoteServerError(e, server)) throw e } @@ -874,7 +878,7 @@ class RemoteServerHandler( if (RemoteServer.UNTRUSTED_MODE) throw new SecurityException( "Remote server is operating is untrusted mode, can not create remote actors on behalf of the remote client") - log.info("Creating a new remote typed actor:\n\t[%s :: %s]", interfaceClassname, targetClassname) + log.slf4j.info("Creating a new remote typed actor:\n\t[{} :: {}]", interfaceClassname, targetClassname) val (interfaceClass, targetClass) = if (applicationLoader.isDefined) (applicationLoader.get.loadClass(interfaceClassname), @@ -887,7 +891,7 @@ class RemoteServerHandler( newInstance } catch { case e => - log.error(e, "Could not create remote typed actor instance") + log.slf4j.error("Could not create remote typed actor instance", e) server.notifyListeners(RemoteServerError(e, server)) throw e } @@ -913,7 +917,8 @@ class RemoteServerHandler( private def createErrorReplyMessage(exception: Throwable, request: RemoteMessageProtocol, actorType: AkkaActorType): RemoteMessageProtocol = { val actorInfo = request.getActorInfo - log.error(exception, "Could not invoke remote actor [%s]", actorInfo.getTarget) + log.slf4j.error("Could not invoke remote actor [{}]", actorInfo.getTarget) + log.slf4j.debug("Could not invoke remote actor", exception) val messageBuilder = RemoteActorSerialization.createRemoteMessageProtocolBuilder( None, Right(request.getUuid), @@ -941,7 +946,7 @@ class RemoteServerHandler( "The remote client [" + clientAddress + "] does not have a secure cookie.") if (!(request.getCookie == RemoteServer.SECURE_COOKIE.get)) throw new SecurityException( "The remote client [" + clientAddress + "] secure cookie is not the same as remote server secure cookie") - log.info("Remote client [%s] successfully authenticated using secure cookie", clientAddress) + log.slf4j.info("Remote client [{}] successfully authenticated using secure cookie", clientAddress) } } } diff --git a/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala b/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala index 98f2161173..c0e49c80c5 100644 --- a/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala +++ b/akka-remote/src/main/scala/akka/serialization/SerializationProtocol.scala @@ -152,7 +152,7 @@ object ActorSerialization { private[akka] def fromProtobufToLocalActorRef[T <: Actor]( protocol: SerializedActorRefProtocol, format: Format[T], loader: Option[ClassLoader]): ActorRef = { - Actor.log.debug("Deserializing SerializedActorRefProtocol to LocalActorRef:\n" + protocol) + Actor.log.slf4j.debug("Deserializing SerializedActorRefProtocol to LocalActorRef:\n" + protocol) val serializer = if (format.isInstanceOf[SerializerBasedActorFormat[_]]) @@ -226,7 +226,7 @@ object RemoteActorSerialization { * Deserializes a RemoteActorRefProtocol Protocol Buffers (protobuf) Message into an RemoteActorRef instance. */ private[akka] def fromProtobufToRemoteActorRef(protocol: RemoteActorRefProtocol, loader: Option[ClassLoader]): ActorRef = { - Actor.log.debug("Deserializing RemoteActorRefProtocol to RemoteActorRef:\n %s", protocol) + Actor.log.slf4j.debug("Deserializing RemoteActorRefProtocol to RemoteActorRef:\n {}", protocol) RemoteActorRef( protocol.getClassOrServiceName, protocol.getActorClassname, @@ -244,7 +244,7 @@ object RemoteActorSerialization { val host = homeAddress.getHostName val port = homeAddress.getPort - Actor.log.debug("Register serialized Actor [%s] as remote @ [%s:%s]", actorClassName, host, port) + Actor.log.slf4j.debug("Register serialized Actor [{}] as remote @ [{}:{}]", Array(actorClassName, host, port)) RemoteServer.getOrCreateServer(homeAddress) ActorRegistry.registerActorByUuid(homeAddress, uuid.toString, ar) @@ -367,7 +367,7 @@ object TypedActorSerialization { private def fromProtobufToLocalTypedActorRef[T <: Actor, U <: AnyRef]( protocol: SerializedTypedActorRefProtocol, format: Format[T], loader: Option[ClassLoader]): U = { - Actor.log.debug("Deserializing SerializedTypedActorRefProtocol to LocalActorRef:\n" + protocol) + Actor.log.slf4j.debug("Deserializing SerializedTypedActorRefProtocol to LocalActorRef:\n" + protocol) val actorRef = ActorSerialization.fromProtobufToLocalActorRef(protocol.getActorRef, format, loader) val intfClass = toClass(loader, protocol.getInterfaceName) TypedActor.newInstance(intfClass, actorRef).asInstanceOf[U] @@ -407,7 +407,7 @@ object RemoteTypedActorSerialization { * Deserializes a RemoteTypedActorRefProtocol Protocol Buffers (protobuf) Message into AW RemoteActorRef proxy. */ private[akka] def fromProtobufToRemoteTypedActorRef[T](protocol: RemoteTypedActorRefProtocol, loader: Option[ClassLoader]): T = { - Actor.log.debug("Deserializing RemoteTypedActorRefProtocol to AW RemoteActorRef proxy:\n" + protocol) + Actor.log.slf4j.debug("Deserializing RemoteTypedActorRefProtocol to AW RemoteActorRef proxy:\n" + protocol) val actorRef = RemoteActorSerialization.fromProtobufToRemoteActorRef(protocol.getActorRef, loader) val intfClass = TypedActorSerialization.toClass(loader, protocol.getInterfaceName) TypedActor.createProxyForRemoteActorRef(intfClass, actorRef).asInstanceOf[T] diff --git a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteActorSample.scala b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteActorSample.scala index cb7a5f36eb..836230d839 100644 --- a/akka-remote/src/test/scala/remote/ServerInitiatedRemoteActorSample.scala +++ b/akka-remote/src/test/scala/remote/ServerInitiatedRemoteActorSample.scala @@ -29,7 +29,7 @@ object ServerInitiatedRemoteActorClient extends Logging { def run = { val actor = RemoteClient.actorFor("hello-service", "localhost", 2552) val result = actor !! "Hello" - log.info("Result from Remote Actor: %s", result) + log.slf4j.info("Result from Remote Actor: {}", result) } def main(args: Array[String]) = run diff --git a/akka-remote/src/test/scala/ticket/Ticket506Spec.scala b/akka-remote/src/test/scala/ticket/Ticket506Spec.scala index 7a15c00a2e..e82d4c5efb 100644 --- a/akka-remote/src/test/scala/ticket/Ticket506Spec.scala +++ b/akka-remote/src/test/scala/ticket/Ticket506Spec.scala @@ -58,4 +58,4 @@ class Ticket506Spec extends Spec with ShouldMatchers { s2.shutdown } } -} \ No newline at end of file +} diff --git a/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnBecome.scala b/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnBecome.scala new file mode 100644 index 0000000000..c762c2da7d --- /dev/null +++ b/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnBecome.scala @@ -0,0 +1,139 @@ +package sample.fsm.dining.become + +//Akka adaptation of +//http://www.dalnefre.com/wp/2010/08/dining-philosophers-in-humus/ + +import akka.actor.{Scheduler, ActorRef, Actor} +import akka.actor.Actor._ +import java.util.concurrent.TimeUnit + +/* + * First we define our messages, they basically speak for themselves + */ +sealed trait DiningHakkerMessage +case class Busy(chopstick: ActorRef) extends DiningHakkerMessage +case class Put(hakker: ActorRef) extends DiningHakkerMessage +case class Take(hakker: ActorRef) extends DiningHakkerMessage +case class Taken(chopstick: ActorRef) extends DiningHakkerMessage +object Eat extends DiningHakkerMessage +object Think extends DiningHakkerMessage + +/* + * A Chopstick is an actor, it can be taken, and put back + */ +class Chopstick(name: String) extends Actor { + self.id = name + + //When a Chopstick is taken by a hakker + //It will refuse to be taken by other hakkers + //But the owning hakker can put it back + def takenBy(hakker: ActorRef): Receive = { + case Take(otherHakker) => + otherHakker ! Busy(self) + case Put(`hakker`) => + become(available) + } + + //When a Chopstick is available, it can be taken by a hakker + def available: Receive = { + case Take(hakker) => + become(takenBy(hakker)) + hakker ! Taken(self) + } + + //A Chopstick begins its existence as available + def receive = available +} + +/* + * A hakker is an awesome dude or dudett who either thinks about hacking or has to eat ;-) + */ +class Hakker(name: String,left: ActorRef, right: ActorRef) extends Actor { + self.id = name + + //When a hakker is thinking it can become hungry + //and try to pick up its chopsticks and eat + def thinking: Receive = { + case Eat => + become(hungry) + left ! Take(self) + right ! Take(self) + } + + //When a hakker is hungry it tries to pick up its chopsticks and eat + //When it picks one up, it goes into wait for the other + //If the hakkers first attempt at grabbing a chopstick fails, + //it starts to wait for the response of the other grab + def hungry: Receive = { + case Taken(`left`) => + become(waiting_for(right,left)) + case Taken(`right`) => + become(waiting_for(left,right)) + case Busy(chopstick) => + become(denied_a_chopstick) + } + + //When a hakker is waiting for the last chopstick it can either obtain it + //and start eating, or the other chopstick was busy, and the hakker goes + //back to think about how he should obtain his chopsticks :-) + def waiting_for(chopstickToWaitFor: ActorRef, otherChopstick: ActorRef): Receive = { + case Taken(`chopstickToWaitFor`) => + log.info("%s has picked up %s and %s, and starts to eat",name,left.id,right.id) + become(eating) + Scheduler.scheduleOnce(self,Think,5,TimeUnit.SECONDS) + + case Busy(chopstick) => + become(thinking) + otherChopstick ! Put(self) + self ! Eat + } + + //When the results of the other grab comes back, + //he needs to put it back if he got the other one. + //Then go back and think and try to grab the chopsticks again + def denied_a_chopstick: Receive = { + case Taken(chopstick) => + become(thinking) + chopstick ! Put(self) + self ! Eat + case Busy(chopstick) => + become(thinking) + self ! Eat + } + + //When a hakker is eating, he can decide to start to think, + //then he puts down his chopsticks and starts to think + def eating: Receive = { + case Think => + become(thinking) + left ! Put(self) + right ! Put(self) + log.info("%s puts down his chopsticks and starts to think",name) + Scheduler.scheduleOnce(self,Eat,5,TimeUnit.SECONDS) + } + + //All hakkers start in a non-eating state + def receive = { + case Think => + log.info("%s starts to think",name) + become(thinking) + Scheduler.scheduleOnce(self,Eat,5,TimeUnit.SECONDS) + } +} + +/* + * Alright, here's our test-harness + */ +object DiningHakkers { + def run { + //Create 5 chopsticks + val chopsticks = for(i <- 1 to 5) yield actorOf(new Chopstick("Chopstick "+i)).start + //Create 5 awesome hakkers and assign them their left and right chopstick + val hakkers = for { + (name,i) <- List("Ghosh","Bonér","Klang","Krasser","Manie").zipWithIndex + } yield actorOf(new Hakker(name,chopsticks(i),chopsticks((i+1) % 5))).start + + //Signal all hakkers that they should start thinking, and watch the show + hakkers.foreach(_ ! Think) + } +} diff --git a/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnFsm.scala b/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnFsm.scala new file mode 100644 index 0000000000..34bc3ba29e --- /dev/null +++ b/akka-samples/akka-sample-fsm/src/main/scala/DiningHakkersOnFsm.scala @@ -0,0 +1,172 @@ +package sample.fsm.dining.fsm + +import akka.actor.{ActorRef, Actor, FSM} +import Actor._ +import java.util.concurrent.TimeUnit +import TimeUnit._ + +/* + * Some messages for the chopstick + */ +sealed trait ChopstickMessage +object Take extends ChopstickMessage +object Put extends ChopstickMessage +case class Taken(chopstick: ActorRef) extends ChopstickMessage +case class Busy(chopstick: ActorRef) extends ChopstickMessage + +/** + * Some states the chopstick can be in + */ +sealed trait ChopstickState +case object Available extends ChopstickState +case object Taken extends ChopstickState + +/** + * Some state container for the chopstick + */ +case class TakenBy(hakker: Option[ActorRef]) + +/* + * A chopstick is an actor, it can be taken, and put back + */ +class Chopstick(name: String) extends Actor with FSM[ChopstickState, TakenBy] { + self.id = name + + // When a chopstick is available, it can be taken by a some hakker + when(Available) { + case Event(Take, _) => + goto(Taken) using TakenBy(self.sender) replying Taken(self) + } + + // When a chopstick is taken by a hakker + // It will refuse to be taken by other hakkers + // But the owning hakker can put it back + when(Taken) { + case Event(Take, currentState) => + stay replying Busy(self) + case Event(Put, TakenBy(hakker)) if self.sender == hakker => + goto(Available) using TakenBy(None) + } + + // A chopstick begins its existence as available and taken by no one + startWith(Available, TakenBy(None)) +} + +/** + * Some fsm hakker messages + */ +sealed trait FSMHakkerMessage +object Think extends FSMHakkerMessage + +/** + * Some fsm hakker states + */ +sealed trait FSMHakkerState +case object Waiting extends FSMHakkerState +case object Thinking extends FSMHakkerState +case object Hungry extends FSMHakkerState +case object WaitForOtherChopstick extends FSMHakkerState +case object FirstChopstickDenied extends FSMHakkerState +case object Eating extends FSMHakkerState + +/** + * Some state container to keep track of which chopsticks we have + */ +case class TakenChopsticks(left: Option[ActorRef], right: Option[ActorRef]) + +/* + * A fsm hakker is an awesome dude or dudette who either thinks about hacking or has to eat ;-) + */ +class FSMHakker(name: String, left: ActorRef, right: ActorRef) extends Actor with FSM[FSMHakkerState, TakenChopsticks] { + self.id = name + + when(Waiting) { + case Event(Think, _) => + log.info("%s starts to think", name) + startThinking(5, SECONDS) + } + + //When a hakker is thinking it can become hungry + //and try to pick up its chopsticks and eat + when(Thinking) { + case Event(StateTimeout, _) => + left ! Take + right ! Take + goto(Hungry) + } + + // When a hakker is hungry it tries to pick up its chopsticks and eat + // When it picks one up, it goes into wait for the other + // If the hakkers first attempt at grabbing a chopstick fails, + // it starts to wait for the response of the other grab + when(Hungry) { + case Event(Taken(`left`), _) => + goto(WaitForOtherChopstick) using TakenChopsticks(Some(left), None) + case Event(Taken(`right`), _) => + goto(WaitForOtherChopstick) using TakenChopsticks(None, Some(right)) + case Event(Busy(_), _) => + goto(FirstChopstickDenied) + } + + // When a hakker is waiting for the last chopstick it can either obtain it + // and start eating, or the other chopstick was busy, and the hakker goes + // back to think about how he should obtain his chopsticks :-) + when(WaitForOtherChopstick) { + case Event(Taken(`left`), TakenChopsticks(None, Some(right))) => startEating(left, right) + case Event(Taken(`right`), TakenChopsticks(Some(left), None)) => startEating(left, right) + case Event(Busy(chopstick), TakenChopsticks(leftOption, rightOption)) => + leftOption.foreach(_ ! Put) + rightOption.foreach(_ ! Put) + startThinking(10, MILLISECONDS) + } + + private def startEating(left: ActorRef, right: ActorRef): State = { + log.info("%s has picked up %s and %s, and starts to eat", name, left.id, right.id) + goto(Eating) using TakenChopsticks(Some(left), Some(right)) forMax (5, SECONDS) + } + + // When the results of the other grab comes back, + // he needs to put it back if he got the other one. + // Then go back and think and try to grab the chopsticks again + when(FirstChopstickDenied) { + case Event(Taken(secondChopstick), _) => + secondChopstick ! Put + startThinking(10, MILLISECONDS) + case Event(Busy(chopstick), _) => + startThinking(10, MILLISECONDS) + } + + // When a hakker is eating, he can decide to start to think, + // then he puts down his chopsticks and starts to think + when(Eating) { + case Event(StateTimeout, _) => + log.info("%s puts down his chopsticks and starts to think", name) + left ! Put + right ! Put + startThinking(5, SECONDS) + } + + private def startThinking(period: Int, timeUnit: TimeUnit): State = { + goto(Thinking) using TakenChopsticks(None, None) forMax (period, timeUnit) + } + + //All hakkers start waiting + startWith(Waiting, TakenChopsticks(None, None)) +} + +/* + * Alright, here's our test-harness + */ +object DiningHakkersOnFsm { + + def run = { + // Create 5 chopsticks + val chopsticks = for (i <- 1 to 5) yield actorOf(new Chopstick("Chopstick " + i)).start + // Create 5 awesome fsm hakkers and assign them their left and right chopstick + val hakkers = for{ + (name, i) <- List("Ghosh", "Bonér", "Klang", "Krasser", "Manie").zipWithIndex + } yield actorOf(new FSMHakker(name, chopsticks(i), chopsticks((i + 1) % 5))).start + + hakkers.foreach(_ ! Think) + } +} diff --git a/akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala b/akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala index 33bdbbcd69..1f85c73100 100644 --- a/akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala +++ b/akka-samples/akka-sample-remote/src/main/scala/ClientManagedRemoteActorSample.scala @@ -12,7 +12,7 @@ import akka.util.Logging class RemoteHelloWorldActor extends RemoteActor("localhost", 2552) { def receive = { case "Hello" => - log.info("Received 'Hello'") + log.slf4j.info("Received 'Hello'") self.reply("World") } } @@ -20,7 +20,7 @@ class RemoteHelloWorldActor extends RemoteActor("localhost", 2552) { object ClientManagedRemoteActorServer extends Logging { def run = { RemoteNode.start("localhost", 2552) - log.info("Remote node started") + log.slf4j.info("Remote node started") } def main(args: Array[String]) = run @@ -30,10 +30,10 @@ object ClientManagedRemoteActorClient extends Logging { def run = { val actor = actorOf[RemoteHelloWorldActor].start - log.info("Remote actor created, moved to the server") - log.info("Sending 'Hello' to remote actor") + log.slf4j.info("Remote actor created, moved to the server") + log.slf4j.info("Sending 'Hello' to remote actor") val result = actor !! "Hello" - log.info("Result from Remote Actor: '%s'", result.get) + log.slf4j.info("Result from Remote Actor: '{}'", result.get) } def main(args: Array[String]) = run diff --git a/akka-samples/akka-sample-remote/src/main/scala/ServerManagedRemoteActorSample.scala b/akka-samples/akka-sample-remote/src/main/scala/ServerManagedRemoteActorSample.scala index 9fe7e19880..b81bc485da 100644 --- a/akka-samples/akka-sample-remote/src/main/scala/ServerManagedRemoteActorSample.scala +++ b/akka-samples/akka-sample-remote/src/main/scala/ServerManagedRemoteActorSample.scala @@ -12,7 +12,7 @@ import akka.util.Logging class HelloWorldActor extends Actor { def receive = { case "Hello" => - log.info("Received 'Hello'") + log.slf4j.info("Received 'Hello'") self.reply("World") } } @@ -21,9 +21,9 @@ object ServerManagedRemoteActorServer extends Logging { def run = { RemoteNode.start("localhost", 2552) - log.info("Remote node started") + log.slf4j.info("Remote node started") RemoteNode.register("hello-service", actorOf[HelloWorldActor]) - log.info("Remote actor registered and started") + log.slf4j.info("Remote actor registered and started") } def main(args: Array[String]) = run @@ -33,10 +33,10 @@ object ServerManagedRemoteActorClient extends Logging { def run = { val actor = RemoteClient.actorFor("hello-service", "localhost", 2552) - log.info("Remote client created") - log.info("Sending 'Hello' to remote actor") + log.slf4j.info("Remote client created") + log.slf4j.info("Sending 'Hello' to remote actor") val result = actor !! "Hello" - log.info("Result from Remote Actor: '%s'", result.get) + log.slf4j.info("Result from Remote Actor: '{}'", result.get) } def main(args: Array[String]) = run diff --git a/akka-stm/src/main/scala/akka/stm/Transaction.scala b/akka-stm/src/main/scala/akka/stm/Transaction.scala index 880a0af05a..07580ab7dd 100644 --- a/akka-stm/src/main/scala/akka/stm/Transaction.scala +++ b/akka-stm/src/main/scala/akka/stm/Transaction.scala @@ -100,24 +100,24 @@ object Transaction { if (JTA_AWARE) Some(ReflectiveJtaModule.createTransactionContainer) else None - log.trace("Creating transaction " + toString) + log.slf4j.trace("Creating transaction " + toString) // --- public methods --------- def begin = synchronized { - log.trace("Starting transaction " + toString) + log.slf4j.trace("Starting transaction " + toString) jta.foreach { _.beginWithStmSynchronization(this) } } def commit = synchronized { - log.trace("Committing transaction " + toString) + log.slf4j.trace("Committing transaction " + toString) persistentStateMap.valuesIterator.foreach(_.commit) status = TransactionStatus.Completed jta.foreach(_.commit) } def abort = synchronized { - log.trace("Aborting transaction " + toString) + log.slf4j.trace("Aborting transaction " + toString) jta.foreach(_.rollback) persistentStateMap.valuesIterator.foreach(_.abort) persistentStateMap.clear diff --git a/akka-stm/src/test/scala/transactor/CoordinatedIncrementSpec.scala b/akka-stm/src/test/scala/transactor/CoordinatedIncrementSpec.scala index e9a2ab20fa..5132cbbeb1 100644 --- a/akka-stm/src/test/scala/transactor/CoordinatedIncrementSpec.scala +++ b/akka-stm/src/test/scala/transactor/CoordinatedIncrementSpec.scala @@ -18,7 +18,7 @@ object CoordinatedIncrement { implicit val txFactory = TransactionFactory(timeout = 3 seconds) def increment = { - log.info(name + ": incrementing") + log.slf4j.info(name + ": incrementing") count alter (_ + 1) } diff --git a/akka-stm/src/test/scala/transactor/FickleFriendsSpec.scala b/akka-stm/src/test/scala/transactor/FickleFriendsSpec.scala index 80a6e0f081..2adfaeca5f 100644 --- a/akka-stm/src/test/scala/transactor/FickleFriendsSpec.scala +++ b/akka-stm/src/test/scala/transactor/FickleFriendsSpec.scala @@ -26,7 +26,7 @@ object FickleFriends { implicit val txFactory = TransactionFactory(timeout = 3 seconds) def increment = { - log.info(name + ": incrementing") + log.slf4j.info(name + ": incrementing") count alter (_ + 1) } @@ -65,7 +65,7 @@ object FickleFriends { implicit val txFactory = TransactionFactory(timeout = 3 seconds) def increment = { - log.info(name + ": incrementing") + log.slf4j.info(name + ": incrementing") count alter (_ + 1) } diff --git a/akka-stm/src/test/scala/transactor/TransactorSpec.scala b/akka-stm/src/test/scala/transactor/TransactorSpec.scala index aeb559c410..c329672486 100644 --- a/akka-stm/src/test/scala/transactor/TransactorSpec.scala +++ b/akka-stm/src/test/scala/transactor/TransactorSpec.scala @@ -20,7 +20,7 @@ object TransactorIncrement { override def transactionFactory = TransactionFactory(timeout = 3 seconds) def increment = { - log.info(name + ": incrementing") + log.slf4j.info(name + ": incrementing") count alter (_ + 1) } @@ -32,7 +32,7 @@ object TransactorIncrement { } override def before = { - case i: Increment => log.info(name + ": before transaction") + case i: Increment => log.slf4j.info(name + ": before transaction") } def atomically = { @@ -44,7 +44,7 @@ object TransactorIncrement { } override def after = { - case i: Increment => log.info(name + ": after transaction") + case i: Increment => log.slf4j.info(name + ": after transaction") } override def normally = { diff --git a/akka-typed-actor/src/main/scala/akka/config/TypedActorGuiceConfigurator.scala b/akka-typed-actor/src/main/scala/akka/config/TypedActorGuiceConfigurator.scala index dc2e010923..fc2f83c5d9 100644 --- a/akka-typed-actor/src/main/scala/akka/config/TypedActorGuiceConfigurator.scala +++ b/akka-typed-actor/src/main/scala/akka/config/TypedActorGuiceConfigurator.scala @@ -43,7 +43,7 @@ private[akka] class TypedActorGuiceConfigurator extends TypedActorConfiguratorBa * @return the typed actors for the class */ def getInstance[T](clazz: Class[T]): List[T] = synchronized { - log.debug("Retrieving typed actor [%s]", clazz.getName) + log.slf4j.debug("Retrieving typed actor [{}]", clazz.getName) if (injector eq null) throw new IllegalActorStateException( "inject() and/or supervise() must be called before invoking getInstance(clazz)") val (proxy, targetInstance, component) = diff --git a/config/logback.xml b/config/logback.xml index 28b4fb5504..403062049f 100644 --- a/config/logback.xml +++ b/config/logback.xml @@ -19,7 +19,7 @@ [%t] [%4p] [%d{ISO8601}] %c{1}: %m%n - ./logs/akka.log.%d{yyyy-MM-dd-HH} + ./logs/akka.log.slf4j.%d{yyyy-MM-dd-HH} diff --git a/project/build/AkkaProject.scala b/project/build/AkkaProject.scala index fbbf09627e..58cfaf185a 100644 --- a/project/build/AkkaProject.scala +++ b/project/build/AkkaProject.scala @@ -406,12 +406,15 @@ class AkkaParentProject(info: ProjectInfo) extends DefaultProject(info) { } class AkkaSampleRemoteProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) + class AkkaSampleFSMProject(info: ProjectInfo) extends AkkaDefaultProject(info, deployPath) class AkkaSamplesParentProject(info: ProjectInfo) extends ParentProject(info) { override def disableCrossPaths = true lazy val akka_sample_ants = project("akka-sample-ants", "akka-sample-ants", new AkkaSampleAntsProject(_), akka_stm) + lazy val akka_sample_fsm = project("akka-sample-fsm", "akka-sample-fsm", + new AkkaSampleFSMProject(_), akka_actor) lazy val akka_sample_remote = project("akka-sample-remote", "akka-sample-remote", new AkkaSampleRemoteProject(_), akka_remote) } @@ -499,978 +502,3 @@ trait DeployProject { self: BasicScalaProject => trait OSGiProject extends BNDPlugin { self: DefaultProject => override def bndExportPackage = Seq("akka.*;version=%s".format(projectVersion.value)) } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -