From: Christos KK Loverdos Date: Fri, 27 Apr 2012 11:28:01 +0000 (+0300) Subject: Enhance [Lazy]Loggable X-Git-Url: https://code.grnet.gr/git/aquarium/commitdiff_plain/b5e4a6e4640a702fa12e46bec6c04f63e32b0e84 Enhance [Lazy]Loggable --- diff --git a/src/main/scala/gr/grnet/aquarium/util/LazyLoggable.scala b/src/main/scala/gr/grnet/aquarium/util/LazyLoggable.scala index e463c44..c3c837e 100644 --- a/src/main/scala/gr/grnet/aquarium/util/LazyLoggable.scala +++ b/src/main/scala/gr/grnet/aquarium/util/LazyLoggable.scala @@ -38,7 +38,7 @@ package gr.grnet.aquarium.util import org.slf4j.LoggerFactory /** - * Like [[gr.grnet.aquarium.util.Loggable]] but the underlying logger is lazily evaluated. + * Like [[gr.grnet.aquarium.util.Loggable]] but the underlying logger is created lazily. * * @author Christos KK Loverdos */ @@ -74,4 +74,8 @@ trait LazyLoggable { protected def logStopped(ms0: Long, ms1: Long, fmt: String, args: Any*): Unit = { LogHelpers.logStopped(this.logger, ms0, ms1, fmt, args: _*) } + + protected def logChainOfCauses(t: Throwable): Unit = { + logger.error("Oops!\n{}", chainOfCauses(t).map("!! " + _) mkString "\n") + } } diff --git a/src/main/scala/gr/grnet/aquarium/util/Loggable.scala b/src/main/scala/gr/grnet/aquarium/util/Loggable.scala index 0624ee1..b5b7184 100644 --- a/src/main/scala/gr/grnet/aquarium/util/Loggable.scala +++ b/src/main/scala/gr/grnet/aquarium/util/Loggable.scala @@ -73,4 +73,8 @@ trait Loggable { protected def logStopped(ms0: Long, ms1: Long, fmt: String, args: Any*): Unit = { LogHelpers.logStopped(this.logger, ms0, ms1, fmt, args: _*) } + + protected def logChainOfCauses(t: Throwable): Unit = { + logger.error("Oops!\n{}", chainOfCauses(t).map("!! " + _) mkString "\n") + } } \ No newline at end of file