From c1f66fe689b91eb5839e8a1db4ac479c627d06cd Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 7 Jun 2022 22:51:47 +0600 Subject: [PATCH] Update README.md --- README.md | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c5d67a8..da1edcb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,65 @@ # How to use -Here is tutorial +![JVM](https://img.shields.io/badge/JVM-red?style=for-the-badge&logo=openjdk&logoColor=white) +![Android](https://img.shields.io/badge/Android-green?style=for-the-badge&logo=android&logoColor=white) +![Js](https://img.shields.io/badge/JavaScript-323330?style=for-the-badge&logo=javascript&logoColor=F7DF1E) + +It is simple logging tool which is using built-in tools for logging: + +* `java.util.logging.Logger` for `JVM` +* `android.util.Log` for `Android` +* `Console` for `JS` + +## How to use + +### Fast-travel + +Just use some boring extensions like: + +```kotlin +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 `KSLog` functions and passed anywhere as `KSLog`) +* 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: + +```kotlin +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 + +[![Maven Central](https://maven-badges.herokuapp.com/maven-central/dev.inmo/kslog/badge.svg)](https://maven-badges.herokuapp.com/maven-central/dev.inmo/kslog) + +### Gradle + +```groovy +implementation "dev.inmo:kslog:$kslog_version" +``` + +### Maven + +```xml + + dev.inmo + kslog + ${kslog_version} + ```