From 5f12ee932b1d5ba28b775058fe35f8d7ba16b1bf Mon Sep 17 00:00:00 2001 From: Ivan Topolnak Date: Tue, 13 Aug 2013 18:50:19 -0300 Subject: wip --- .../src/main/scala/kamon/logging/UowActorLogging.scala | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'kamon-uow/src/main') diff --git a/kamon-uow/src/main/scala/kamon/logging/UowActorLogging.scala b/kamon-uow/src/main/scala/kamon/logging/UowActorLogging.scala index 2347bbe9..64c5241a 100644 --- a/kamon-uow/src/main/scala/kamon/logging/UowActorLogging.scala +++ b/kamon-uow/src/main/scala/kamon/logging/UowActorLogging.scala @@ -2,13 +2,23 @@ package kamon.logging import akka.actor.Actor import kamon.{Tracer, Kamon} +import akka.event.{BusLogging, LogSource, LoggingAdapter} trait UowActorLogging { - self: Actor => + this: Actor => - def logWithUOW(text: String) = { - val uow = Tracer.context.map(_.userContext).getOrElse("NA") - println(s"=======>[$uow] - $text") + val log = { + val (str, clazz) = LogSource(this, context.system) + new BusLogging(context.system.eventStream, str, clazz) with UowLoggingAdapter } } + +trait UowLoggingAdapter extends LoggingAdapter { + def currentUow: String = Tracer.context().flatMap(_.userContext).map(_.toString).getOrElse("") + protected abstract override def notifyWarning(message: String) = super.notifyWarning(s"[${currentUow}] - $message") + protected abstract override def notifyInfo(message: String) = super.notifyInfo( s"[${currentUow}] - $message") + protected abstract override def notifyDebug(message: String) = super.notifyDebug( s"[${currentUow}] - $message") + protected abstract override def notifyError(message: String) = super.notifyError( s"[${currentUow}] - $message") + protected abstract override def notifyError(cause: Throwable, message: String) = super.notifyError(cause, s"[${currentUow}] - $message") +} -- cgit v1.2.3