improvements in microutils

This commit is contained in:
InsanusMokrassar 2023-01-14 13:22:07 +06:00
parent 99c0f06b72
commit e0bdd5dfdc
2 changed files with 18 additions and 1 deletions

View File

@ -5,6 +5,7 @@
* `Startup`:
* `Launcher`:
* Improvements in `StartLauncherPlugin#start` methods
* Add opportunity to pass second argument on `JVM` platform as log level
* `Repos`:
* `Ktor`:
* `Client`:

View File

@ -1,6 +1,7 @@
package dev.inmo.micro_utils.startup.launcher
import dev.inmo.kslog.common.KSLog
import dev.inmo.kslog.common.LogLevel
import dev.inmo.kslog.common.i
import kotlinx.serialization.json.jsonObject
import java.io.File
@ -23,10 +24,25 @@ import java.io.File
* In that case in `build/distributions` folder you will be able to find zip and tar files with all required
* tools for application running (via their `bin/app_name` binary). In that case yoy will not need to pass
* `--args=...` and launch will look like `./bin/app_name sample.config.json`
*
* ## Debug mode
*
* You may pass the second parameter, one of [LogLevel] enum variants to setup [KSLog] minimal logging level. Sample:
*
* ```bash
* ./gradlew run --args="sample.config.json DEBUG" // enable debugging output
* ```
*
* OR
* ```bash
* ./gradlew run --args="sample.config.json WARNING" // enable logging since WARNING
* ```
*
* **Default level is [LogLevel.INFO]**
*/
suspend fun main(args: Array<String>) {
KSLog.default = KSLog("Launcher")
KSLog.default = KSLog("Launcher", args.getOrNull(1) ?.let { LogLevel.valueOf(it) } ?: LogLevel.INFO)
val (configPath) = args
val file = File(configPath)
KSLog.i("Start read config from ${file.absolutePath}")