Skip to content

Instantly share code, notes, and snippets.

@momania
Created August 29, 2011 12:05
Show Gist options
  • Save momania/1178259 to your computer and use it in GitHub Desktop.
Save momania/1178259 to your computer and use it in GitHub Desktop.
Single line logging evenhandler
akka {
event-handlers = ["com.acme.logging.MySlf4jEventHandler"]
event-handler-level = "INFO"
}
package com.acme.logging
import akka.actor.Actor
import akka.event.EventHandler
import akka.event.slf4j.{Logger, Logging}
class MySlf4jEventHandler extends Actor with Logging {
import EventHandler._
self.id = ID
self.dispatcher = EventHandlerDispatcher
def receive = {
case Error(cause, instance, message) =>
Logger(instance.getClass).error(message.toString, cause)
case Warning(instance, message) =>
Logger(instance.getClass).warn(message.toString)
case Info(instance, message) =>
Logger(instance.getClass).info(message.toString)
case Debug(instance, message) =>
Logger(instance.getClass).debug(message.toString)
case event => log.debug(event.toString)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment