Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: logging #102

Closed
wcarmon opened this issue Mar 30, 2018 · 3 comments
Closed

Documentation: logging #102

wcarmon opened this issue Mar 30, 2018 · 3 comments
Labels
core status:accepted accepted to be developed
Milestone

Comments

@wcarmon
Copy link
Contributor

wcarmon commented Mar 30, 2018

https://insert-koin.io/docs/1.0/reference/logging/

For posterity, can you add an example of how to replace the Logger (eg. Koin.logger = AndroidLogger()) or EmptyLogger()

@arnaudgiuliani arnaudgiuliani added this to the 1.0.0 milestone Apr 16, 2018
@roelandxyz
Copy link

To integrate the logging with ktor and slf4j I did something like this:

This is the logger implementation:

import org.koin.log.Logger

class KoinLogger(private val logger: org.slf4j.Logger) : Logger {

    private val prefix = "(KOIN) :: "

    override fun debug(msg: String) {
        logger.debug(prefix + msg)
    }
    override fun err(msg: String) {
        logger.error(prefix + msg)
    }
    override fun log(msg: String) {
        logger.info(prefix + msg)
    }
}

Here is how I use it:

fun Application.init() {
    Koin.logger = KoinLogger(environment.log)
    startKoin(arrayListOf(KoinModule))

    install(DefaultHeaders)
    install(CallLogging) {
        level = Level.INFO
    }
    ...

@arnaudgiuliani arnaudgiuliani added core status:accepted accepted to be developed labels May 3, 2018
@arnaudgiuliani
Copy link
Member

You just need an implementation of Logger Koin class, and pass it to your startKoin().

Doc will be updated for this.

@arnaudgiuliani
Copy link
Member

Check #143 for more info about new documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core status:accepted accepted to be developed
Projects
None yet
Development

No branches or pull requests

3 participants