Matti MK
12/30/2021, 10:33 AMKermit
in `KaMPKit`: I can see that a logger instance is created for every location where it’s being used (https://github.com/touchlab/KaMPKit/blob/main/shared/src/commonMain/kotlin/co/touchlab/kampkit/Koin.kt#L63). Is this simply for the tag
? If there’s no need to switch tags, then is there any upside to injecting Logger
vs just calling the static methods like Logger.i { "something" }
kpgalligan
12/30/2021, 3:35 PMTAG = "NameOfTheClassImIn"
everywhere, so it's an alternative to that. There is no logical benefit of injected vs global if you aren't localizing tags. There is some performance benefit, presumably, as you can have immutable config. All global access goes through some form of concurrent-safe instance access. That means volatile on JVM and an atomic on native (old or new memory model). It's not something I'd worry about in most cases, but as a "logging library publisher" we went a little deep on these considerations.Matti MK
12/30/2021, 5:43 PMkpgalligan
12/30/2021, 10:03 PMthe pattern in KaMPKit felt a bit unfamiliar coming from Timber/LogThe tag thing is really an android thing, and while I'm used to it after the years of Android, when you step back and look at it, it's kind of weird (to me) to need to pass in a tag for every log call. The kermit pattern lets you do that, or just config the tag once and use the same instance everywhere.
kpgalligan
12/30/2021, 10:05 PMiosMain
that gets called from the iOS app's AppDelegate on startup.Matti MK
12/31/2021, 1:27 PMOn “recommended way in providing the config?“, I’m not sure what you meanI was referring what you were mentioned, which is, for example, the helper function on
iosMain
.
What kind of crash? You shouldn’t get crashes, obviouslyProbably something wrong with my own logic here to be honest
Matti MK
12/31/2021, 1:28 PMinternal val loggerModule = module {
val debug = Config.isDebug()
Logger.setLogWriters(listOf(DebugLogWriter(debug)))
Logger.setMinSeverity(if (true) Severity.Verbose else Severity.Verbose)
}
Where the internals of the DebugLogWriter
are as follows:
override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) {
KermitLogger.log(severity = severity, message = message, tag = tag, throwable = throwable)
}
Matti MK
12/31/2021, 1:30 PMDebugLogWriter
simply to override the isLoggable
, as the log
calls are simply piped directly back to Kermit