@@ -83,6 +83,16 @@ private[scalalogging] object LoggerTakingImplicitMacro {
83
83
}
84
84
}
85
85
86
+ def errorCode [A ](c : LoggerContext [A ])(body : c.Expr [Unit ])(a : c.Expr [A ]): c.universe.Tree = {
87
+ import c .universe ._
88
+ val underlying = q " ${c.prefix}.underlying "
89
+ val canLogEv = q " ${c.prefix}.canLogEv "
90
+ q """ if ( $underlying.isErrorEnabled) {
91
+ $underlying.error( $canLogEv.logMessage( $body))
92
+ $canLogEv.afterLog( $a)
93
+ } """
94
+ }
95
+
86
96
// Warn
87
97
88
98
def warnMessage [A ](c : LoggerContext [A ])(message : c.Expr [String ])(a : c.Expr [A ]): c.universe.Tree = {
@@ -159,6 +169,16 @@ private[scalalogging] object LoggerTakingImplicitMacro {
159
169
}
160
170
}
161
171
172
+ def warnCode [A ](c : LoggerContext [A ])(body : c.Expr [Unit ])(a : c.Expr [A ]): c.universe.Tree = {
173
+ import c .universe ._
174
+ val underlying = q " ${c.prefix}.underlying "
175
+ val canLogEv = q " ${c.prefix}.canLogEv "
176
+ q """ if ( $underlying.isWarnEnabled) {
177
+ $underlying.warn( $canLogEv.logMessage( $body))
178
+ $canLogEv.afterLog( $a)
179
+ } """
180
+ }
181
+
162
182
// Info
163
183
164
184
def infoMessage [A ](c : LoggerContext [A ])(message : c.Expr [String ])(a : c.Expr [A ]): c.universe.Tree = {
@@ -235,6 +255,16 @@ private[scalalogging] object LoggerTakingImplicitMacro {
235
255
}
236
256
}
237
257
258
+ def infoCode [A ](c : LoggerContext [A ])(body : c.Expr [Unit ])(a : c.Expr [A ]): c.universe.Tree = {
259
+ import c .universe ._
260
+ val underlying = q " ${c.prefix}.underlying "
261
+ val canLogEv = q " ${c.prefix}.canLogEv "
262
+ q """ if ( $underlying.isInfoEnabled) {
263
+ $underlying.info( $canLogEv.logMessage( $body))
264
+ $canLogEv.afterLog( $a)
265
+ } """
266
+ }
267
+
238
268
// Debug
239
269
240
270
def debugMessage [A ](c : LoggerContext [A ])(message : c.Expr [String ])(a : c.Expr [A ]): c.universe.Tree = {
@@ -311,6 +341,17 @@ private[scalalogging] object LoggerTakingImplicitMacro {
311
341
}
312
342
}
313
343
344
+ def debugCode [A ](c : LoggerContext [A ])(body : c.Expr [Unit ])(a : c.Expr [A ]): c.universe.Tree = {
345
+ import c .universe ._
346
+ val underlying = q " ${c.prefix}.underlying "
347
+ val canLogEv = q " ${c.prefix}.canLogEv "
348
+ q """ if ( $underlying.isDebugEnabled) {
349
+ $underlying.debug( $canLogEv.logMessage( $body))
350
+ $canLogEv.afterLog( $a)
351
+ } """
352
+ }
353
+
354
+
314
355
// Trace
315
356
316
357
def traceMessage [A ](c : LoggerContext [A ])(message : c.Expr [String ])(a : c.Expr [A ]): c.universe.Tree = {
@@ -386,4 +427,14 @@ private[scalalogging] object LoggerTakingImplicitMacro {
386
427
} """
387
428
}
388
429
}
430
+
431
+ def traceCode [A ](c : LoggerContext [A ])(body : c.Expr [Unit ])(a : c.Expr [A ]): c.universe.Tree = {
432
+ import c .universe ._
433
+ val underlying = q " ${c.prefix}.underlying "
434
+ val canLogEv = q " ${c.prefix}.canLogEv "
435
+ q """ if ( $underlying.isTraceEnabled) {
436
+ $underlying.trace( $canLogEv.logMessage( $body))
437
+ $canLogEv.afterLog( $a)
438
+ } """
439
+ }
389
440
}
0 commit comments