Created
January 11, 2022 15:00
-
-
Save Sivan757/16e0c26a98e9bdf348ed5eb22e2982f5 to your computer and use it in GitHub Desktop.
Kotlin logging
This file contains 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
class AnyClass { | |
val log = logger() | |
} |
This file contains 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
/** | |
* 日志拓展文件 | |
* | |
* @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