logging method's calling stack even in multiple threads.
scalacOptions += "-Xplugin-require:macroparadise"
resolvers += Resolver.bintrayIvyRepo("scalameta", "maven")
addCompilerPlugin("org.scalameta" % "paradise" % "3.0.0-M9" cross CrossVersion.full)
libraryDependencies += "com.scalachan" % "meta-logger_2.12" % "0.1"
import lorance.metalog._
object Main extends App with MetaLogger {
NeedLog.something
}
object NeedLog {
@Log(Info() :: Nil, printLogger)
def something() {
"hello world"
}
}
meta annotation @Log
/@LogFuture
affect a method at compile pre-process time:
//before
@Log(Info() :: Nil, printLogger)
def add1(x: Int) = {
x + 1
}
//after parsed, ===> simple as:
def add1(x: Int)(implicit metaLogContext: LogContext) = {
println(s"current time - metaLogContext.logId.id - ... param: ${x}")
val result = { x + 1 }
println(s"current time - metaLogContext.logId.id - ... result: ${result}")
result
}
- add a @VirtualLog for trait def (seems some bug in scalameta at this point)