Added generic event handler
This commit is contained in:
parent
c8f1d10c62
commit
dd69a4b763
2 changed files with 7 additions and 5 deletions
|
|
@ -123,6 +123,7 @@ object EventHandler extends ListenerManagement {
|
|||
val warning = "[WARN] [%s] [%s] [%s] %s".intern
|
||||
val info = "[INFO] [%s] [%s] [%s] %s".intern
|
||||
val debug = "[DEBUG] [%s] [%s] [%s] %s".intern
|
||||
val generic = "[GENERIC] [%s] [%s]".intern
|
||||
val ID = "default:error:handler".intern
|
||||
|
||||
val EventHandlerDispatcher = Dispatchers.newExecutorBasedEventDrivenDispatcher(ID).build
|
||||
|
|
@ -136,6 +137,8 @@ object EventHandler extends ListenerManagement {
|
|||
"Configuration option 'akka.event-handler-level' is invalid [" + unknown + "]")
|
||||
}
|
||||
|
||||
def notify(event: => AnyRef) = notifyListeners(event)
|
||||
|
||||
def notify[T <: Event : ClassManifest](event: => T) {
|
||||
if (classManifest[T].erasure.asInstanceOf[Class[_ <: Event]] == level) notifyListeners(event)
|
||||
}
|
||||
|
|
@ -195,7 +198,8 @@ object EventHandler extends ListenerManagement {
|
|||
event.thread.getName,
|
||||
instance.getClass.getSimpleName,
|
||||
message))
|
||||
case _ => {}
|
||||
case event =>
|
||||
println(generic.format(formattedTimestamp, event.toString))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -265,9 +269,7 @@ object Actor extends ListenerManagement {
|
|||
type Receive = PartialFunction[Any, Unit]
|
||||
|
||||
private[actor] val actorRefInCreation = new scala.util.DynamicVariable[Option[ActorRef]](None)
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates an ActorRef out of the Actor with type T.
|
||||
* <pre>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ akka {
|
|||
time-unit = "seconds" # Time unit for all timeout properties throughout the config
|
||||
|
||||
event-handlers = ["akka.actor.EventHandler$DefaultListener"] # event handlers to register at boot time (EventHandler$DefaultListener logs to STDOUT)
|
||||
event-handler-level = "DEBUG" # Options: ERROR, WARING, INFO, DEBUG
|
||||
event-handler-level = "DEBUG" # Options: ERROR, WARNING, INFO, DEBUG
|
||||
|
||||
# These boot classes are loaded (and created) automatically when the Akka Microkernel boots up
|
||||
# Can be used to bootstrap your application(s)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue