Created
June 2, 2017 06:37
-
-
Save arturaz/56722e9203050e4f4cc28488e54610b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage | |
log.debug(s"Writing batched data to DB (singles: ${data.size}, arrays ${arrayData.size})") | |
// Implementation | |
def debug(message: String): Unit = macro LoggerMacro.debugMessage | |
// Macro | |
def debugMessage(c: LoggerContext)(message: c.Expr[String]) = { | |
import c.universe._ | |
val underlying = q"${c.prefix}.underlying" | |
q"if ($underlying.isDebugEnabled) $underlying.debug($message)" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
type LoggerContext = Context { type PrefixType = Logger }