AAkira / Napier

Logging library for Kotlin Multiplatform
Apache License 2.0
786 stars 34 forks source link

Does not work within async #69

Closed erksch closed 3 years ago

erksch commented 3 years ago

I am trying to log with Napier from within an async block.

fun testLog() = coroutineScope {
    someList.map { element ->
        async {
            Napier.d( "Processing $element")
            someSuspendFunc(element)
            Napier.d("Done processing $element")
        }
    }.awaitAll()
}

Running the code in iOS gives the following error:

kotlin.native.IncorrectDereferenceException: Trying to access top level value not marked as @ThreadLocal or @SharedImmutable from non-main thread

Any solution for this?

AAkira commented 3 years ago

Please check 2.0.0-alpha2