@@ -261,30 +261,41 @@ private[scalalogging] object LoggerMacro {
261
261
case _ => (message, Seq .empty)
262
262
}
263
263
}
264
- def formatArgs (args : Expr [Seq [Any ]])(using q : Quotes ): Seq [Expr [AnyRef ]] = {
264
+
265
+ def formatArgs (args : Expr [Seq [Any ]])(using q : Quotes
266
+
267
+ ):
268
+ Seq [Expr [AnyRef ]] = {
265
269
import quotes .reflect .*
266
270
import util .*
267
- // we recursively obtain the actual value of inline parameters
268
- def map (term: Term ) = {
271
+ // we recursively obtain the actual value of inline parameters
272
+ def map (term : Term ) = {
269
273
term match {
270
274
case t if t.tpe <:< TypeRepr .of[AnyRef ] => t.asExprOf[AnyRef ]
271
- case t => ' {$ {t.asExpr}.asInstanceOf [AnyRef ]}
275
+ case t => ' {
276
+ $ {
277
+ t.asExpr
278
+ }.asInstanceOf [AnyRef ]
279
+ }
272
280
}
273
281
}
282
+
274
283
def rec (tree : Term ): Option [Seq [Expr [AnyRef ]]] = tree match {
275
284
case Repeated (elems, _) => Some (elems.map(map))
276
285
case Block (Nil , e) => rec(e)
286
+ case tped@ Typed (Ident (_), _) =>
287
+ tped.symbol.tree match {
288
+ case ValDef (_, _, Some (rhs)) => rec(rhs)
289
+ case _ => None
290
+ }
277
291
case Typed (e, _) => rec(e)
278
292
case Inlined (_, Nil , e) => rec(e)
279
- // Seq():_*, List():_* , forceVarargs(1,2):_*e.g.,
280
- case Apply (TypeApply (_, _), List (Typed (Repeated (elems, _),_))) =>
293
+ case Apply (TypeApply (_, _), List (Typed (Repeated (elems, _), _))) =>
281
294
Some (elems.map(map))
282
- case Ident (name) =>
283
- // todo
284
- None
285
- case _ =>
295
+ case _ =>
286
296
None
287
297
}
298
+
288
299
rec(args.asTerm).getOrElse(Seq .empty)
289
300
}
290
301
}
0 commit comments