!act #3012 Remove deprecated event-handlers

This commit is contained in:
Patrik Nordwall 2013-12-11 11:16:09 +01:00
parent f50d293fdc
commit 67b9cec8a4
7 changed files with 15 additions and 96 deletions

View file

@ -1,53 +0,0 @@
/**
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.config
import scala.concurrent.duration._
import akka.testkit.AkkaSpec
import akka.actor.Actor
import akka.event.Logging.InitializeLogger
import akka.event.Logging.LogEvent
import akka.event.Logging.LoggerInitialized
import akka.event.Logging.Error
import akka.util.Timeout
object DeprecatedEventHandlerSpec {
case class WrappedLogEvent(event: Any)
class TestEventHandler extends Actor {
def receive = {
case init: InitializeLogger
sender ! LoggerInitialized
case err: Error
context.system.eventStream.publish(WrappedLogEvent(err))
case event: LogEvent
}
}
}
@org.junit.runner.RunWith(classOf[org.scalatest.junit.JUnitRunner])
class DeprecatedEventHandlerSpec extends AkkaSpec("""
akka.event-handlers = ["akka.config.DeprecatedEventHandlerSpec$TestEventHandler"]
akka.event-handler-startup-timeout = 17s
""") {
import DeprecatedEventHandlerSpec._
"Akka 2.2" must {
"use deprected event-handler properties" in {
system.settings.EventHandlers must be(List(classOf[TestEventHandler].getName))
system.settings.EventHandlerStartTimeout must be(Timeout(17.seconds))
system.eventStream.subscribe(testActor, classOf[WrappedLogEvent])
system.log.error("test error")
expectMsgPF(remaining) {
case WrappedLogEvent(Error(_, _, _, "test error"))
}
}
}
}

View file

@ -16,17 +16,11 @@ akka {
# to STDOUT)
loggers = ["akka.event.Logging$DefaultLogger"]
# Deprecated, use akka.loggers.
event-handlers = []
# Loggers are created and registered synchronously during ActorSystem
# start-up, and since they are actors, this timeout is used to bound the
# waiting time
logger-startup-timeout = 5s
# Deprecated, use akka.logger-startup-timeout
event-handler-startup-timeout = -1s
# Log level used by the configured loggers (see "loggers") as soon
# as they have been started; before that, see "stdout-loglevel"
# Options: OFF, ERROR, WARNING, INFO, DEBUG

View file

@ -146,10 +146,6 @@ object ActorSystem {
final val StdoutLogLevel: String = getString("akka.stdout-loglevel")
final val Loggers: immutable.Seq[String] = immutableSeq(getStringList("akka.loggers"))
final val LoggerStartTimeout: Timeout = Timeout(Duration(getMilliseconds("akka.logger-startup-timeout"), MILLISECONDS))
@deprecated("use Loggers)", "2.2")
final val EventHandlers: immutable.Seq[String] = immutableSeq(getStringList("akka.event-handlers"))
@deprecated("use LoggerStartTimeout)", "2.2")
final val EventHandlerStartTimeout: Timeout = Timeout(Duration(getMilliseconds("akka.event-handler-startup-timeout"), MILLISECONDS))
final val LogConfigOnStart: Boolean = config.getBoolean("akka.log-config-on-start")
final val LogDeadLetters: Int = config.getString("akka.log-dead-letters").toLowerCase match {
case "off" | "false" 0

View file

@ -99,14 +99,9 @@ trait LoggingBus extends ActorEventBus {
ErrorLevel
}
try {
val defaultLoggers = system.settings.EventHandlers match {
case Nil system.settings.Loggers match {
case Nil classOf[DefaultLogger].getName :: Nil
case loggers loggers
}
case loggers
publish(Warning(logName, this.getClass, "[akka.event-handlers] config is deprecated, use [akka.loggers]"))
loggers
val defaultLoggers = system.settings.Loggers match {
case Nil classOf[DefaultLogger].getName :: Nil
case loggers loggers
}
val myloggers =
for {
@ -142,9 +137,9 @@ trait LoggingBus extends ActorEventBus {
}
} catch {
case e: Exception
System.err.println("error while starting up EventHandler")
System.err.println("error while starting up loggers")
e.printStackTrace()
throw new ConfigurationException("Could not start Event Handler due to [" + e.toString + "]")
throw new ConfigurationException("Could not start logger due to [" + e.toString + "]")
}
}
@ -177,13 +172,7 @@ trait LoggingBus extends ActorEventBus {
private def addLogger(system: ActorSystemImpl, clazz: Class[_ <: Actor], level: LogLevel, logName: String): ActorRef = {
val name = "log" + Extension(system).id() + "-" + simpleName(clazz)
val actor = system.systemActorOf(Props(clazz), name)
implicit def timeout =
if (system.settings.EventHandlerStartTimeout.duration >= Duration.Zero) {
publish(Warning(logName, this.getClass,
"[akka.event-handler-startup-timeout] config is deprecated, use [akka.logger-startup-timeout]"))
system.settings.EventHandlerStartTimeout
} else system.settings.LoggerStartTimeout
implicit def timeout = system.settings.LoggerStartTimeout
import akka.pattern.ask
val response = try Await.result(actor ? InitializeLogger(this), timeout.duration) catch {
case _: TimeoutException

View file

@ -5,4 +5,4 @@
################################
Migration from 2.1.x to 2.2.x is described in the
`documentation of 2.2 <http://doc.akka.io/docs/akka/2.2.1/project/migration-guide-2.0.x-2.1.x.html>`_.
`documentation of 2.2 <http://doc.akka.io/docs/akka/2.2.3/project/migration-guide-2.1.x-2.2.x.html>`_.

View file

@ -98,4 +98,11 @@ Changed cluster expected-response-after configuration
Configuration property ``akka.cluster.failure-detector.heartbeat-request.expected-response-after``
has been renamed to ``akka.cluster.failure-detector.expected-response-after``.
Removed Deprecated Features
===========================
The following, previously deprecated features have been removed:
* `event-handlers renamed to loggers <http://doc.akka.io/docs/akka/2.2.3/project/migration-guide-2.1.x-2.2.x.html#event-handlers_renamed_to_loggers>`_

View file

@ -1,14 +0,0 @@
/**
* Copyright (C) 2009-2013 Typesafe Inc. <http://www.typesafe.com>
*/
package akka.event.slf4j
import akka.event.Logging.Warning
@deprecated("use akka.event.slf4j.Slf4jLogger)", "2.2")
class Slf4jEventHandler extends Slf4jLogger {
self ! Warning(getClass.getName, getClass,
s"[${getClass.getName}] is deprecated, use [${classOf[Slf4jLogger].getName}] instead")
}