diff options
author | Ivan Topolnak <ivantopo@gmail.com> | 2013-08-13 18:50:19 -0300 |
---|---|---|
committer | Ivan Topolnak <ivantopo@gmail.com> | 2013-08-13 18:50:19 -0300 |
commit | 5f12ee932b1d5ba28b775058fe35f8d7ba16b1bf (patch) | |
tree | ce063f2a917b4eb3115e718e998ad99454f54fc4 /kamon-uow/src | |
parent | 18656c723881ebfd8ade43a990fe73beba5690d0 (diff) | |
download | Kamon-5f12ee932b1d5ba28b775058fe35f8d7ba16b1bf.tar.gz Kamon-5f12ee932b1d5ba28b775058fe35f8d7ba16b1bf.tar.bz2 Kamon-5f12ee932b1d5ba28b775058fe35f8d7ba16b1bf.zip |
wip
Diffstat (limited to 'kamon-uow/src')
-rw-r--r-- | kamon-uow/src/main/scala/kamon/logging/UowActorLogging.scala | 18 |
1 files changed, 14 insertions, 4 deletions
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") +} |