mirror of
https://github.com/InsanusMokrassar/KSLog.git
synced 2025-10-24 16:10:10 +00:00
33a0d9032fe77676f9ad84ec541d03c6065f0562
How to use
It is simple logging tool which is using built-in tools for logging:
java.util.logging.LoggerforJVMandroid.util.LogforAndroidConsoleforJS
How to use
Fast-travel
Just use some boring extensions like:
KSLog.i("Some message")
// OR
KSLog.i("Some tag", "Some message")
// OR
KSLog.i("Some tag", "Some message", IllegalArgumentException("So, that is exception :)"))
// OR EVEN
KSLog.l(LogLevel.INFO, "Some tag", "Some message", IllegalArgumentException("So, that is exception :)"))
A little bit deeper
There are several important things in context of this library:
- Default logger (available via
KSLog) - Local logger (can be created via
KSLogfunctions and passed anywhere asKSLog) - Logging shortcuts like
KSLog.i/KSLog.info
Default logger can be created by passing defaultTag and one of variants log level filters: set or minimal loggable level. In JVM you also may setup any logger as base logger for default realizations of KSLog. Besides, you may use your own callback (on any target platform) as output of logging:
val logger = KSLog { logLevel, optionalTag, message, optionalThrowable ->
println("[$logLevel] $optionalTag - $message: $optionalThrowable.stackTraceToString()")
}
In the example above we will take the logger which will just print incoming data as common output.
Installation
Gradle
implementation "dev.inmo:kslog:$kslog_version"
Maven
<dependency>
<groupId>dev.inmo</groupId>
<artifactId>kslog</artifactId>
<version>${kslog_version}</version>
</dependency>
Languages
Kotlin
99%
Shell
1%