I wanted to use Napier logging on main thread and ...
# kotlin-native
m
I wanted to use Napier logging on main thread and background threads (when using coroutines-native-mt). This is what I came up with
Copy code
fun initLogging() {
    Napier.base(DebugAntilog())
    GlobalScope.launch {
        withContext(Dispatchers.Default) {
            Napier.base(DebugAntilog())
        }
    }
}
Is there a less hacky way to achieve that? I assume I need a different Napier instance on each thread, since they are
@ThreadLocal
, right?
Okay, I can see that other people have similar problems and solutions: https://github.com/AAkira/Napier/issues/56
111 Views