I Missed Flutter's debugPrint After Moving to Kotlin
Описание и применение
Библиотека debugprint упрощает отладочный вывод в Kotlin, автоматически включая логирование в debug‑сборках, извлекая информацию о вызывающем и поддерживая ленивые сообщения.
Задача
Developers migrating from Flutter to Kotlin find Android's Log.d verbose and repetitive, hindering quick debugging during development.
Результат
The library reduces boilerplate, automatically toggles logging per build type, derives caller information, supports lazy evaluation, and isolates logging failures from application crashes, improving developer productivity.
Рабочий процесс
- Add dependency: implementation("com.flagodna:debugprint:0.1.1")
- Use API: debugPrint.d("Loading user...")
- Optionally set custom tag: debugPrint.d("Auth", "Token expired")
- Disable automatic tagging: DebugPrint.autoTag = false
- Use lazy messages: debugPrint.d{ "User: ${expensiveOperation()}" }
- Replace sink if needed: DebugPrint.sink = CustomSink()
Доказательства
I built one. GitHub: https://github.com/cas8398/debugprint
debugPrint.d("Loading user...")
debugPrint automatically enables logging for debug builds and disables it for release builds.
debugPrint.d{ "User: ${expensiveOperation()}" }
- Дата записи: 2026-10-02T17:41:12.116Z