A Flutter-inspired, debug-only logger for Android, written in Kotlin.
DebugPrint gives you a familiar debugPrint.d("hello") API, auto-detects debug
builds, auto-tags logs with File.fn:line, and stays completely silent in release.
- 🎯 Flutter-style API —
debugPrint.d("msg"),dprint.e("Tag", "oops"),dlog.w { ... } - 🔇 Silent in release — auto-enabled in debug, auto-disabled in release
- ⚙️ Zero config — no
init()call, noApplicationsetup, noBuildConfigwiring - 📍 Auto tag —
File.function:linederived from the caller (toggleable) - 🧵 Lazy messages —
debugPrint.d { "expensive $x" }never builds the string when disabled - 🎚️ Log levels —
.v .d .i .w .e - 🏷️ Custom tags —
debugPrint.d("Auth", "token expired") - 🔌 Pluggable sinks — swap Logcat for file / Crashlytics / remote
- 🛡️ Never crashes — logging errors are swallowed silently
- 📦 Tiny — pure Kotlin, one small AAR
implementation("com.flagodna:debugprint:0.1.1")import com.flagodna.debugprint.debugPrint
debugPrint.d("Hello from debugPrint!")
debugPrint.i("User signed in")
debugPrint.w("Cache miss")
debugPrint.e("Payment failed")
debugPrint.v("Verbose detail")debugPrint.d("Auth", "token about to expire")
debugPrint.e("Payments", "charge declined")Use the lambda overload for anything expensive:
debugPrint.d { "user = $user, size = ${bigList.size}" }The string is only built if logging is enabled.
All three names point to the same object:
debugPrint.d("short")
dprint.d("shorter")
dlog.d("shortest")| Method | Logcat level |
|---|---|
.v |
VERBOSE |
.d |
DEBUG |
.i |
INFO |
.w |
WARN |
.e |
ERROR |
Each level supports:
debugPrint.d("message") // auto tag
debugPrint.d("Tag", "message") // custom tag
debugPrint.d { "message" } // lazy| Build type | DebugPrint.enabled |
Output |
|---|---|---|
| Debug | true (auto) |
Logcat |
| Release | false (auto) |
(nothing) |
The enabled flag is set once, automatically, before Application.onCreate()
runs. No setup in your Application class is required.
Implement DebugPrintSink to route logs anywhere:
import com.flagodna.debugprint.DebugPrintSink
class FileSink(private val file: File) : DebugPrintSink {
override fun print(level: Int, tag: String, message: String) {
file.appendText("[$level] $tag: $message\n")
}
}
DebugPrint.sink = FileSink(File(context.filesDir, "app.log"))A sink must never throw — DebugPrint swallows any exception from a sink.
- Non-lambda calls —
debugPrint.d("msg")is a field read + a branch when disabled. - Lambda calls —
debugPrint.d { "msg" }skips string construction entirely when disabled. - Auto-tag — costs a stack walk per call. Disable for hot loops:
DebugPrint.autoTag = false
for (i in 1..100_000) debugPrint.d("iteration $i") // fast, tag = defaultTag
DebugPrint.autoTag = trueOr pass a custom tag, which also skips the stack walk:
for (i in 1..100_000) debugPrint.d("Loop", "iteration $i")