mirror of
https://github.com/InsanusMokrassar/docs.git
synced 2025-12-16 03:05:35 +00:00
update dependencies and logs for telegram bot api
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user