Skip to content

Commit a42ddcb

Browse files
prateekatknoldusanalytically
authored andcommitted
added ***Code() methods in LoggerTakingImplicitMacro
1 parent 3adf7d9 commit a42ddcb

File tree

1 file changed

+27
-6
lines changed

1 file changed

+27
-6
lines changed

src/main/scala-3/com/typesafe/scalalogging/LoggerTakingImplicitMacro.scala

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ private[scalalogging] object LoggerTakingImplicitMacro {
6060
}}
6161
}
6262

63-
64-
63+
def errorCode[A:Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], body: Expr[Unit])(a: Expr[A])(using Quotes) =
64+
'{if ($underlying.isErrorEnabled) {
65+
$body
66+
$canLogEv.afterLog($a)
67+
}}
6568

6669
// Warn
6770

@@ -117,9 +120,13 @@ private[scalalogging] object LoggerTakingImplicitMacro {
117120
}}
118121
}
119122

123+
def warnCode[A: Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], body: Expr[Unit])(a: Expr[A])(using Quotes) =
124+
'{ if ($underlying.isWarnEnabled) {
125+
$body
126+
$canLogEv.afterLog($a)
127+
}}
120128

121129

122-
123130
// Info
124131

125132
def infoMessage[A: Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], message: Expr[String])(a: Expr[A])(using Quotes): Expr[Unit] =
@@ -174,9 +181,13 @@ private[scalalogging] object LoggerTakingImplicitMacro {
174181
}}
175182
}
176183

184+
def infoCode[A: Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], body: Expr[Unit])(a: Expr[A])(using Quotes) =
185+
'{ if ($underlying.isInfoEnabled) {
186+
$body
187+
$canLogEv.afterLog($a)
188+
}}
177189

178190

179-
180191
// Debug
181192

182193
def debugMessage[A: Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], message: Expr[String])(a: Expr[A])(using Quotes): Expr[Unit] =
@@ -231,9 +242,13 @@ private[scalalogging] object LoggerTakingImplicitMacro {
231242
}}
232243
}
233244

245+
def debugCode[A: Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], body: Expr[Unit])(a: Expr[A])(using Quotes) =
246+
'{ if ($underlying.isDebugEnabled) {
247+
$body
248+
$canLogEv.afterLog($a)
249+
}}
250+
234251

235-
236-
237252
// Trace
238253

239254
def traceMessage[A: Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], message: Expr[String])(a: Expr[A])(using Quotes): Expr[Unit] =
@@ -287,4 +302,10 @@ private[scalalogging] object LoggerTakingImplicitMacro {
287302
$canLogEv.afterLog($a)
288303
}}
289304
}
305+
306+
def traceCode[A: Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], body: Expr[Unit])(a: Expr[A])(using Quotes) =
307+
'{ if ($underlying.isTraceEnabled) {
308+
$body
309+
$canLogEv.afterLog($a)
310+
}}
290311
}

0 commit comments

Comments
 (0)