Open AliAzaz opened 2 years ago
I've implemented koin in my kmm project and for network I'm using Ktor but I noticed that Ktor logging is not working when implemented using Koin DI however it is working if I directly place ktor http code inside file.
Here is my code snippet:
Versions: ktorVersion = "2.0.2" koinVersion = "3.2.0"
Koin class
fun initKoin(appDeclaration: KoinAppDeclaration = {}) { startKoin { appDeclaration() modules(commonModule(enableNetworkLogs), platformModule()) }.apply { initLogger() } } fun commonModule() = module { single { createKoinClient(get()) } single { NetworkModule(get(), baseURL = "https://gitcdn.link/cdn/KaterinaPetrova/") } } fun createKoinClient(httpClientEngine: HttpClientEngine) = HttpClient(httpClientEngine) { install(Logging) { level = LogLevel.HEADERS logger = object : Logger { override fun log(message: String) { Napier.e(tag = "Http Request", message = message) } } } install(ContentNegotiation) { json(Json { isLenient = true; ignoreUnknownKeys = true }) } }
@KaterinaPetrova your reply required.
I've implemented koin in my kmm project and for network I'm using Ktor but I noticed that Ktor logging is not working when implemented using Koin DI however it is working if I directly place ktor http code inside file.
Here is my code snippet:
Versions: ktorVersion = "2.0.2" koinVersion = "3.2.0"
Koin class