Created
August 29, 2011 12:05
-
-
Save momania/1178259 to your computer and use it in GitHub Desktop.
Single line logging evenhandler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
akka { | |
event-handlers = ["com.acme.logging.MySlf4jEventHandler"] | |
event-handler-level = "INFO" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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