
Facilitates application log observation and management with a Ktor plugin for network request monitoring, enhancing debugging and analysis. Offers debug-only implementation to optimize performance.
Welcome to LogKMPanion! This Kotlin Multiplatform library is designed to help you observe and manage application logs across Android and iOS platforms. With a convenient Ktor plugin, LogKMPanion also allows you to monitor network request logs effortlessly.
implementation("io.github.idfinance-oss:logkmpanion:$version")fun addToLogKMPanion(type: LogType, tag: String, message: String)In Android:
fun openLogKMPanion(context: Context)In iOS
fun LogKMPanionViewControllerProvider(onClose: () -> Unit): UIViewControllerTo display api calls:
Add plugin to Ktor:
fun logKMPanionNetworkPlugin(sessionId: String = uuid4().toString()) //sessionId argument should be passed in case you have multiple http clientsThe panel can also switch the app between backend environments. The library knows nothing about
hosts, storage or how a switch is applied: the app supplies an EnvironmentProvider, and the
Environment tab shows up only while one is registered.
object AppEnvironmentProvider : EnvironmentProvider {
override val environments = listOf(
DebugEnvironment(id = "staging", title = "Staging", host = "staging.example.com"),
DebugEnvironment(id = "production", title = "Production", host = "example.com"),
// isHostEditable renders a text field, so an ad-hoc host such as a per-PR
// review environment can be typed in
DebugEnvironment(id = "custom", title = "Custom host", host = "", isHostEditable = true),
)
override val current: Flow<DebugEnvironment> = ...
override suspend fun select(id: String, host: String?) {
// persist the choice and rebuild the network stack;
// most apps simply restart themselves here
}
}Register it once during startup, before the panel can be opened:
LogKMPanion.setEnvironmentProvider(AppEnvironmentProvider)Worth knowing:
host is non-null only for entries with isHostEditable and carries the value the user typed.current is a Flow, which Swift cannot construct, so a
Swift-only implementation is not possible.select may never return: an app that restarts its process to apply the switch dies inside it.null removes the provider and hides the tab again.This project utilizes the following technologies:
The library also provides empty implementation (logkmpanion-no-impl module) with the same
interface (package name and method class names) as logkmpanion module.
So, u can implement logkmpanion module in debug builds and use logkmpanion-no-impl in release mode.
EnvironmentProvider and DebugEnvironment are part of that empty implementation too, so a provider
written by the app still compiles in release builds, where setEnvironmentProvider does nothing.
implementation("io.github.idfinance-oss:logkmpanion-no-impl:$version")Welcome to LogKMPanion! This Kotlin Multiplatform library is designed to help you observe and manage application logs across Android and iOS platforms. With a convenient Ktor plugin, LogKMPanion also allows you to monitor network request logs effortlessly.
implementation("io.github.idfinance-oss:logkmpanion:$version")fun addToLogKMPanion(type: LogType, tag: String, message: String)In Android:
fun openLogKMPanion(context: Context)In iOS
fun LogKMPanionViewControllerProvider(onClose: () -> Unit): UIViewControllerTo display api calls:
Add plugin to Ktor:
fun logKMPanionNetworkPlugin(sessionId: String = uuid4().toString()) //sessionId argument should be passed in case you have multiple http clientsThe panel can also switch the app between backend environments. The library knows nothing about
hosts, storage or how a switch is applied: the app supplies an EnvironmentProvider, and the
Environment tab shows up only while one is registered.
object AppEnvironmentProvider : EnvironmentProvider {
override val environments = listOf(
DebugEnvironment(id = "staging", title = "Staging", host = "staging.example.com"),
DebugEnvironment(id = "production", title = "Production", host = "example.com"),
// isHostEditable renders a text field, so an ad-hoc host such as a per-PR
// review environment can be typed in
DebugEnvironment(id = "custom", title = "Custom host", host = "", isHostEditable = true),
)
override val current: Flow<DebugEnvironment> = ...
override suspend fun select(id: String, host: String?) {
// persist the choice and rebuild the network stack;
// most apps simply restart themselves here
}
}Register it once during startup, before the panel can be opened:
LogKMPanion.setEnvironmentProvider(AppEnvironmentProvider)Worth knowing:
host is non-null only for entries with isHostEditable and carries the value the user typed.current is a Flow, which Swift cannot construct, so a
Swift-only implementation is not possible.select may never return: an app that restarts its process to apply the switch dies inside it.null removes the provider and hides the tab again.This project utilizes the following technologies:
The library also provides empty implementation (logkmpanion-no-impl module) with the same
interface (package name and method class names) as logkmpanion module.
So, u can implement logkmpanion module in debug builds and use logkmpanion-no-impl in release mode.
EnvironmentProvider and DebugEnvironment are part of that empty implementation too, so a provider
written by the app still compiles in release builds, where setEnvironmentProvider does nothing.
implementation("io.github.idfinance-oss:logkmpanion-no-impl:$version")