File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
main/scala-2/com/typesafe/scalalogging
test/scala/com/typesafe/scalalogging Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -295,7 +295,7 @@ private[scalalogging] object LoggerMacro {
295295 private def formatArgs (c : LoggerContext )(args : c.Expr [Any ]* ) = {
296296 import c .universe ._
297297 args.map { arg =>
298- c.Expr [AnyRef ](if (arg.tree.tpe <:< weakTypeOf[AnyRef ]) arg.tree else q " $arg.asInstanceOf[_root_.scala.AnyRef] " )
298+ c.Expr [AnyRef ](if (arg.tree.tpe <:< weakTypeOf[AnyRef ]) q " $ arg: _root_.scala.AnyRef " else q " $arg.asInstanceOf[_root_.scala.AnyRef] " )
299299 }
300300 }
301301}
Original file line number Diff line number Diff line change @@ -451,6 +451,13 @@ class LoggerSpec extends AnyWordSpec with Matchers with Varargs with MockitoSuga
451451 logger.error(s """ foo\nbar $arg1""" )
452452 verify(underlying).error(s """ foo\nbar {} """ , arg1)
453453 }
454+
455+ " call the underlying format method when interpolated argument is a Throwable" in {
456+ val f = fixture(_.isErrorEnabled, isEnabled = true )
457+ import f ._
458+ logger.error(s """ foo\nbar $arg7""" )
459+ verify(underlying).error(s """ foo\nbar {} """ , arg7ref)
460+ }
454461 }
455462
456463 " Logging a message using slf4 interpolator and Any args" should {
@@ -587,6 +594,8 @@ class LoggerSpec extends AnyWordSpec with Matchers with Varargs with MockitoSuga
587594 val arg5ref = arg5.asInstanceOf [AnyRef ]
588595 val arg6 = 6L
589596 val arg6ref = arg6.asInstanceOf [AnyRef ]
597+ val arg7 = new Throwable
598+ val arg7ref = arg7.asInstanceOf [AnyRef ]
590599 val underlying = mock[org.slf4j.Logger ]
591600 when(p(underlying)).thenReturn(isEnabled)
592601 val logger = Logger (underlying)
You can’t perform that action at this time.
0 commit comments