update dependencies and logs for telegram bot api

This commit is contained in:
2023-11-25 13:15:34 +06:00
parent 347896dbac
commit 603f3c0fda
3 changed files with 267 additions and 237 deletions

View File

@@ -3,13 +3,29 @@
In this library we are using [KSLog](/kslog) for logging of events in telegram bots. There are several ways to set it
up and configure.
* Globally, you may change [DefaultKTgBotAPIKSLog]() logger __BEFORE__ creating of your bots
* Granular, you may configure and pass `logger` variable to the `KtorRequestsExecutor`
Besides, you always may pass your logger to the bot via `KtorRequestsExecutorBuilder`:
```kotlin
// (1)
setDefaultKSLog(
KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? ->
println(defaultMessageFormatter(level, tag, message, throwable))
}
)
// (2)
DefaultKTgBotAPIKSLog = KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? ->
println(defaultMessageFormatter(level, tag, message, throwable))
}
// (3)
val bot = telegramBot(YOUR_TOKEN) {
logger = KSLog("SomeLogger")
logger = KSLog { level: LogLevel, tag: String?, message: Any, throwable: Throwable? ->
println(defaultMessageFormatter(level, tag, message, throwable))
}
}
```
1. This variant will set __GLOBAL DEFAULT__ logger. For example, if you will use somewhere `TagLogger`, it will use
`KSLog.default` under the hood
2. All the bots created after this setup will use new logger until more specified logger configured (see below)
3. Passing of `logger` variable to the `KtorRequestsExecutor` or one of factories
`telegrabBot` will lead to granular setup of logging