Koin: Set custom logger before startKoin() in Android

Created on 13 Feb 2018  路  8Comments  路  Source: InsertKoinIO/koin

Is there any way to set custom Logger for koin before startKoin in android App?
Or maybe set Logger as a parameter for startKoin.
Main issue with current AndroidLogger() is that it's set in Application.startKoin() and make visible all KOIN logs to everyone in release builds.

Most helpful comment

Available in 0.9.0-alpha-5. startKoin has now an optional parameter for Koin logger logger.

All 8 comments

Hello,

Koin logging is set by default with startKoin. I will add the ability to set the needed logger.

Stay in touch.

Thanks

Agreed, it should never log anything by default.

My solution to this issue was to manually remove the Android logger.
You can use it meanwhile...

//startKoin here
 Koin.logger = if (isDebugMode())
            org.koin.android.logger.AndroidLogger() else
            org.koin.log.EmptyLogger()

Passing an extra param to enable logs is the best solution.

I was thinking about putting Koin.logger as nullable and check in startKoin if it's not already set, to put the default value. It would allow to write Koin.logger = EmptyLogger() before startKoin, if we are in release.

I'll prefer an optional parameter Logger for Application.startKoin()

Ok to make it as an optional param.

Available in 0.9.0-alpha-5. startKoin has now an optional parameter for Koin logger logger.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leodeleon22 picture leodeleon22  路  4Comments

LukasAnda picture LukasAnda  路  3Comments

TedHoryczun picture TedHoryczun  路  4Comments

iRYO400 picture iRYO400  路  3Comments

sankarsana picture sankarsana  路  4Comments