Skip to content

Instantly share code, notes, and snippets.

@Sivan757
Created January 11, 2022 15:00
Show Gist options
  • Save Sivan757/16e0c26a98e9bdf348ed5eb22e2982f5 to your computer and use it in GitHub Desktop.
Save Sivan757/16e0c26a98e9bdf348ed5eb22e2982f5 to your computer and use it in GitHub Desktop.
Kotlin logging
class AnyClass {
val log = logger()
}
/**
* 日志拓展文件
*
* @author sivan
*/
inline fun <reified T> T.logger(): Logger {
if (T::class.isCompanion) {
return LoggerFactory.getLogger(T::class.java.enclosingClass)
}
return LoggerFactory.getLogger(T::class.java)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment