Skip to content

Scala-3: Added the missing when***Enabled() methods in LoggerTakingImplicitImpl under scala-3 package #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,6 @@ private[scalalogging] object LoggerTakingImplicitMacro {
}"""
}


// Trace

def traceMessage[A](c: LoggerContext[A])(message: c.Expr[String])(a: c.Expr[A]): c.universe.Tree = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ trait LoggerTakingImplicitImpl[A] {
inline def error(inline marker: Marker, inline message: String, inline args: Any*)(implicit inline a: A): Unit =
${LoggerTakingImplicitMacro.errorMessageArgsMarker('underlying, 'canLogEv, 'marker,'message, 'args)('a)}


inline def whenErrorEnabled(inline body: Unit)(implicit inline a: A): Unit = ${LoggerTakingImplicitMacro.errorCode('underlying, 'canLogEv, 'body)('a)}

// Warn

Expand All @@ -49,6 +49,8 @@ trait LoggerTakingImplicitImpl[A] {
inline def warn(inline marker: Marker, inline message: String, inline args: Any*)(implicit inline a: A): Unit =
${LoggerTakingImplicitMacro.warnMessageArgsMarker('underlying, 'canLogEv, 'marker,'message, 'args)('a)}

inline def whenWarnEnabled(inline body: Unit)(implicit inline a: A): Unit = ${LoggerTakingImplicitMacro.warnCode('underlying, 'canLogEv, 'body)('a)}



// Info
Expand All @@ -71,6 +73,7 @@ trait LoggerTakingImplicitImpl[A] {
inline def info(inline marker: Marker, inline message: String, inline args: Any*)(implicit inline a: A): Unit =
${LoggerTakingImplicitMacro.infoMessageArgsMarker('underlying, 'canLogEv, 'marker,'message, 'args)('a)}

inline def whenInfoEnabled(inline body: Unit)(implicit inline a: A): Unit = ${LoggerTakingImplicitMacro.infoCode('underlying, 'canLogEv, 'body)('a)}


// Debug
Expand All @@ -93,7 +96,7 @@ trait LoggerTakingImplicitImpl[A] {
inline def debug(inline marker: Marker, inline message: String, inline args: Any*)(implicit inline a: A): Unit =
${LoggerTakingImplicitMacro.debugMessageArgsMarker('underlying, 'canLogEv, 'marker,'message, 'args)('a)}


inline def whenDebugEnabled(inline body: Unit)(implicit inline a: A): Unit = ${LoggerTakingImplicitMacro.debugCode('underlying, 'canLogEv, 'body)('a)}

// Trace

Expand All @@ -114,4 +117,6 @@ trait LoggerTakingImplicitImpl[A] {

inline def trace(inline marker: Marker, inline message: String, inline args: Any*)(implicit inline a: A): Unit =
${LoggerTakingImplicitMacro.traceMessageArgsMarker('underlying, 'canLogEv, 'marker,'message, 'args)('a)}

inline def whenTraceEnabled(inline body: Unit)(implicit inline a: A): Unit = ${LoggerTakingImplicitMacro.traceCode('underlying, 'canLogEv, 'body)('a)}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,11 @@ private[scalalogging] object LoggerTakingImplicitMacro {
}}
}



def errorCode[A:Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], body: Expr[Unit])(a: Expr[A])(using Quotes) =
'{if ($underlying.isErrorEnabled) {
$body
$canLogEv.afterLog($a)
}}

// Warn

Expand Down Expand Up @@ -117,9 +120,13 @@ private[scalalogging] object LoggerTakingImplicitMacro {
}}
}

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



// Info

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

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



// Debug

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

def debugCode[A: Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], body: Expr[Unit])(a: Expr[A])(using Quotes) =
'{ if ($underlying.isDebugEnabled) {
$body
$canLogEv.afterLog($a)
}}




// Trace

def traceMessage[A: Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], message: Expr[String])(a: Expr[A])(using Quotes): Expr[Unit] =
Expand Down Expand Up @@ -287,4 +302,10 @@ private[scalalogging] object LoggerTakingImplicitMacro {
$canLogEv.afterLog($a)
}}
}

def traceCode[A: Type](underlying: Expr[Underlying], canLogEv: Expr[CanLog[A]], body: Expr[Unit])(a: Expr[A])(using Quotes) =
'{ if ($underlying.isTraceEnabled) {
$body
$canLogEv.afterLog($a)
}}
}