mirror of
https://github.com/InsanusMokrassar/PlaguBot.git
synced 2024-11-22 07:33:46 +00:00
fixes in logging
This commit is contained in:
parent
f9f56f6afb
commit
37fd9f39d3
@ -2,7 +2,6 @@ package dev.inmo.plagubot
|
|||||||
|
|
||||||
import dev.inmo.kslog.common.*
|
import dev.inmo.kslog.common.*
|
||||||
import dev.inmo.plagubot.config.*
|
import dev.inmo.plagubot.config.*
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import kotlinx.serialization.InternalSerializationApi
|
import kotlinx.serialization.InternalSerializationApi
|
||||||
import kotlinx.serialization.json.jsonObject
|
import kotlinx.serialization.json.jsonObject
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package dev.inmo.plagubot
|
package dev.inmo.plagubot
|
||||||
|
|
||||||
import dev.inmo.kslog.common.d
|
import dev.inmo.kslog.common.*
|
||||||
import dev.inmo.kslog.common.logger
|
|
||||||
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
import dev.inmo.tgbotapi.extensions.api.bot.getMe
|
||||||
import dev.inmo.tgbotapi.extensions.api.send.reply
|
import dev.inmo.tgbotapi.extensions.api.send.reply
|
||||||
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
import dev.inmo.tgbotapi.extensions.behaviour_builder.BehaviourContext
|
||||||
@ -32,8 +31,8 @@ class HelloPlugin : Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override suspend fun BehaviourContext.setupBotPlugin(koin: Koin) {
|
override suspend fun BehaviourContext.setupBotPlugin(koin: Koin) {
|
||||||
logger.d(koin.get<HelloPluginConfig>().print)
|
logger.d { koin.get<HelloPluginConfig>().print }
|
||||||
logger.d(getMe().toString())
|
logger.dS { getMe().toString() }
|
||||||
onCommand("hello_world") {
|
onCommand("hello_world") {
|
||||||
reply(it, "Hello :)")
|
reply(it, "Hello :)")
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ data class PlaguBot(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.onFailure { e ->
|
}.onFailure { e ->
|
||||||
logger.log(LogLevel.WARNING, "Unable to load DI part of $it", e)
|
logger.w("Unable to load DI part of $it", e)
|
||||||
}.getOrNull()
|
}.getOrNull()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -59,14 +59,14 @@ data class PlaguBot(
|
|||||||
config.plugins.map {
|
config.plugins.map {
|
||||||
launch {
|
launch {
|
||||||
runCatchingSafely {
|
runCatchingSafely {
|
||||||
logger.info("Start loading of $it")
|
logger.i("Start loading of $it")
|
||||||
with(it) {
|
with(it) {
|
||||||
setupBotPlugin(koin)
|
setupBotPlugin(koin)
|
||||||
}
|
}
|
||||||
}.onFailure { e ->
|
}.onFailure { e ->
|
||||||
logger.log(LogLevel.WARNING, "Unable to load bot part of $it", e)
|
logger.w("Unable to load bot part of $it", e)
|
||||||
}.onSuccess {
|
}.onSuccess {
|
||||||
logger.info("Complete loading of $it")
|
logger.i("Complete loading of $it")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.joinAll()
|
}.joinAll()
|
||||||
@ -78,26 +78,26 @@ data class PlaguBot(
|
|||||||
suspend fun start(
|
suspend fun start(
|
||||||
scope: CoroutineScope = CoroutineScope(Dispatchers.IO)
|
scope: CoroutineScope = CoroutineScope(Dispatchers.IO)
|
||||||
): Job {
|
): Job {
|
||||||
logger.info("Start initialization")
|
logger.i("Start initialization")
|
||||||
val koinApp = KoinApplication.init()
|
val koinApp = KoinApplication.init()
|
||||||
koinApp.modules(
|
koinApp.modules(
|
||||||
module {
|
module {
|
||||||
setupDI(config.databaseConfig.database, json)
|
setupDI(config.databaseConfig.database, json)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
logger.info("Modules loaded")
|
logger.i("Modules loaded")
|
||||||
GlobalContext.startKoin(koinApp)
|
GlobalContext.startKoin(koinApp)
|
||||||
logger.info("Koin started")
|
logger.i("Koin started")
|
||||||
lateinit var behaviourContext: BehaviourContext
|
lateinit var behaviourContext: BehaviourContext
|
||||||
bot.buildBehaviour(scope = scope) {
|
bot.buildBehaviour(scope = scope) {
|
||||||
logger.info("Start setup of bot part")
|
logger.i("Start setup of bot part")
|
||||||
behaviourContext = this
|
behaviourContext = this
|
||||||
setupBotPlugin(koinApp.koin)
|
setupBotPlugin(koinApp.koin)
|
||||||
deleteWebhook()
|
deleteWebhook()
|
||||||
}
|
}
|
||||||
logger.info("Behaviour builder has been setup")
|
logger.i("Behaviour builder has been setup")
|
||||||
return bot.startGettingOfUpdatesByLongPolling(scope = behaviourContext, updatesFilter = behaviourContext).also {
|
return bot.startGettingOfUpdatesByLongPolling(scope = behaviourContext, updatesFilter = behaviourContext).also {
|
||||||
logger.info("Long polling has been started")
|
logger.i("Long polling has been started")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user