GrantLogger

A lightweight logging utility for the Grant library's internal diagnostics — missing Info.plist keys, unregistered opt-in modules, Settings-navigation failures, and similar edge cases the library itself detects.

This is not a step-by-step audit trail of every permission flow (requested/granted/denied/ rationale-shown/settings-opened) — that is dev.brewkits.grant.GrantEventListener, a separate, purpose-built mechanism attached per dev.brewkits.grant.GrantHandler. The two are complementary: this one for "something the library wants a developer to notice", dev.brewkits.grant.GrantEventListener for "what happened in this permission flow".

Android: the default console output needs logHandler on retail devices

The built-in console output (enabled via isEnabled alone) is a plain Kotlin println. On Android, println/System.out is routed to Logcat only on userdebug/eng system images (emulators, most physical dev/test hardware) — a retail user-build device (the OS type on essentially every phone a real user carries: ro.build.type=user, ro.debuggable=0) never forwards it, silently. isEnabled = true with no logHandler is therefore enough to see Grant's diagnostics on an emulator but produces nothing visible on a real production device — verified against a physical Android 17 device in this project's own test pass. To see logs there, install a logHandler that calls android.util.Log.d/w/e (or a crash reporter / analytics SDK) instead of relying on the console branch.

Usage Example

GrantLogger.isEnabled = true
GrantLogger.logHandler = { level, tag, message ->
MyAnalytics.log("[$tag] $message")
}

Types

Link copied to clipboard

Log severity levels.

Properties

Link copied to clipboard

Enables the built-in console output.

Link copied to clipboard
var logHandler: (level: GrantLogger.LogLevel, tag: String, message: String) -> Unit?

A custom sink for library logs.

Functions

Link copied to clipboard
fun d(tag: String, message: String)

Logs a debug message.

Link copied to clipboard
fun e(tag: String, message: String, error: Throwable? = null)

Logs an error message with an optional exception.

Link copied to clipboard
fun i(tag: String, message: String)

Logs an informational message.

Link copied to clipboard
fun w(tag: String, message: String)

Logs a warning message.