Lens-Logger
1.1.0indexedFacilitates code sharing across Android and iOS platforms, organizing shared code into structured folders for platform-specific implementations and integrating with SwiftUI for iOS apps.
Facilitates code sharing across Android and iOS platforms, organizing shared code into structured folders for platform-specific implementations and integrating with SwiftUI for iOS apps.
LensLogger is a Kotlin Multiplatform (KMP) library for Android, iOS and Desktop that makes debugging network requests effortless. It automatically logs all Ktor network requests and responses, and provides a built-in UI to inspect these logs directly in your app. This helps you quickly identify issues and monitor network activity during development.
OkHttpClient (Android and JVM desktop)| Android | iOS | Desktop (Windows) |
|---|---|---|
![]() | ![]() |
Add the LensLogger artifact to your module's commonMain dependencies:
dependencies {
implementation("io.github.farhazulmullick:lens-logger:<version>")
}
Or add to your libs.versions.toml:
lensLoggerVersion = "<version>"
lens-logger = { module = "io.github.farhazulmullick:lens-logger", version.ref = "lensLoggerVersion" }
In your shared code (e.g., commonMain):
import io.github.farhazulmullick.lenslogger.*
import io.ktor.client.*
import io.ktor.client.engine.*
import io.ktor.client.plugins.logging.*
client = HttpClient(engine) {
LensHttpLogger {
level = LogLevel.ALL
logger = : Logger {
{
Napier.d(message = message)
}
}
}.also {
Napier.base(DebugAntilog())
}
}
client = HttpClient(engine) {
install(LensHttpLogger){
level = LogLevel.ALL
}
}
Install LensOkHttpInterceptor on the application interceptor chain of the OkHttpClient you use with Retrofit (or any OkHttp-based API). The library exposes a small helper:
import io.github.farhazulmullick.lenslogger.plugin.network.installLensInterceptor
import okhttp3.OkHttpClient
val okHttpClient = OkHttpClient.Builder()
.installLensInterceptor()
// other interceptors, timeouts, etc.
.build()
Equivalent without the extension:
import io.github.farhazulmullick.lenslogger.plugin.network.LensOkHttpInterceptor
OkHttpClient.Builder()
.addInterceptor(LensOkHttpInterceptor())
.build()
Calls made through this client appear in the same network log store as Ktor traffic, so they show up in the Lens inspector and respect the same mocking rules where applicable. The interceptor uses blocking work internally; keep it on clients that run network I/O off the main thread (typical for Retrofit).
LensApp)When your root UI is Compose, wrap your app with LensApp. That adds a draggable FAB that opens the bottom sheet inspector (LensContent). Pass dataStores if you use the DataStore tab.
import io.github.farhazulmullick.lenslogger.ui.LensApp
import androidx.compose.ui.Modifier
LensApp(
modifier = Modifier.fillMaxSize(),
showLensFAB = true,
sheetGesturesEnabled = false,
dataStores = myDataStores,
) {
App()
}
There is no separate window-level ComposeView overlay on activities: the FAB lives in your Compose tree only.
Note: Wire at least one of Ktor (step 1) or OkHttp (step 2) so the Network tab has traffic to show.
LensAndroid)If you do not have a single Compose root (classic Activity / XML / fragments), skip LensApp and call LensAndroid.install once from on the main thread. That posts a that opens (full-screen inspector). Configuration only needs a (return an empty list if you do not use DataStore in Lens).
import android.app.Application
import io.github.farhazulmullick.lenslogger.ui.LensAndroid
import io.github.farhazulmullick.lenslogger.ui.LensInstallConfiguration
class MyApp : Application() {
override fun onCreate() {
super.onCreate()
LensAndroid.install(
this,
LensInstallConfiguration(dataStoresProvider = { ctx -> emptyList() }),
)
}
}
Register the application class in the manifest (android:name=".MyApp"). Call LensAndroid.uninstall(this) with the same Application to cancel the notification and clear cached DataStores. After the user grants POST_NOTIFICATIONS (API 33+), call LensAndroid.refreshPersistentNotification(application) if the notification was not shown at install time.
iOS: use your own navigation to embed or present the shared inspector UI as needed; the notification-based entry point is Android-only.
This project is licensed under the MIT License - see the LICENSE file for details.

![]() |
Application.onCreateLensActivitydataStoresProviderSurfaced from shared tags and platforms — no rankings paid for.