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 {
295
295
private def formatArgs (c : LoggerContext )(args : c.Expr [Any ]* ) = {
296
296
import c .universe ._
297
297
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] " )
299
299
}
300
300
}
301
301
}
Original file line number Diff line number Diff line change @@ -451,6 +451,13 @@ class LoggerSpec extends AnyWordSpec with Matchers with Varargs with MockitoSuga
451
451
logger.error(s """ foo\nbar $arg1""" )
452
452
verify(underlying).error(s """ foo\nbar {} """ , arg1)
453
453
}
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
+ }
454
461
}
455
462
456
463
" Logging a message using slf4 interpolator and Any args" should {
@@ -587,6 +594,8 @@ class LoggerSpec extends AnyWordSpec with Matchers with Varargs with MockitoSuga
587
594
val arg5ref = arg5.asInstanceOf [AnyRef ]
588
595
val arg6 = 6L
589
596
val arg6ref = arg6.asInstanceOf [AnyRef ]
597
+ val arg7 = new Throwable
598
+ val arg7ref = arg7.asInstanceOf [AnyRef ]
590
599
val underlying = mock[org.slf4j.Logger ]
591
600
when(p(underlying)).thenReturn(isEnabled)
592
601
val logger = Logger (underlying)
You can’t perform that action at this time.
0 commit comments