Kodio 0.1.5 Help

Logging

Kodio includes a lightweight, multiplatform logging facade in space.kodio.core.logging. As a library, it stays silent by default so your app controls when and where logs appear; nothing is printed to the console unless you opt in.

Enable logging

Call Kodio.configureLogging { } at application startup (for example in main(), Application.onCreate, or your Compose entry point):

import space.kodio.core.Kodio import space.kodio.core.logging.LogLevel import space.kodio.core.logging.platformLogWriter Kodio.configureLogging { minLevel = LogLevel.Debug addWriter(platformLogWriter()) }

platformLogWriter() is a built-in writer that routes output to the platform console:

Platform

Output

Android

Logcat

iOS / macOS

NSLog

JVM / Desktop

stdout / stderr

JS / Wasm

Browser console

You can also configure logging directly via KodioLogging:

import space.kodio.core.logging.KodioLogging import space.kodio.core.logging.LogLevel import space.kodio.core.logging.platformLogWriter KodioLogging.configure { minLevel = LogLevel.Info addWriter(platformLogWriter()) }

Disable logging

Logging is off by default. If you never call configureLogging, Kodio stays silent. To explicitly disable output:

Kodio.configureLogging { minLevel = LogLevel.None }

Or clear writers:

KodioLogging.clearWriters()

Log levels

Levels are defined by the LogLevel enum. A message is emitted when its level is at or above the configured minLevel:

Trace

Very verbose diagnostics: per-sample or per-chunk detail. Use sparingly.

Debug

Routine internal diagnostics useful during development.

Info

Lifecycle milestones: recording started, device selected, session released.

Warn

Recoverable problems: fallback paths, deprecated usage, missing optional features.

Error

Failures and caught exceptions. Prefer error(throwable) { } to attach the cause.

None

Disables all output when set as minLevel.

Bridge to a custom backend

Implement KodioLogWriter, a single-method functional interface, to forward Kodio logs to any backend (Kermit, SLF4J, Crashlytics, your own logger):

import space.kodio.core.Kodio import space.kodio.core.logging.LogLevel Kodio.configureLogging { minLevel = LogLevel.Warn addWriter { level, tag, message, throwable -> MyLogger.log(level.name, tag, message, throwable) } }

You can register multiple writers; each log event is forwarded to every registered writer. Use setWriters() to replace the full set, addWriter() to append, and clearWriters() to remove all.

Create loggers

Use kodioLogger(name) to obtain a tagged logger with lazy message evaluation:

import space.kodio.core.logging.kodioLogger private val logger = kodioLogger("MyComponent") fun doWork() { logger.debug { "Starting work" } logger.info { "Work complete" } logger.warn { "Recoverable issue: ${details()}" } logger.error(exception) { "Operation failed" } }

Messages are evaluated only when the configured minLevel allows the event through. Check whether a level would emit with KodioLogging.isLoggable(level).

Platform coverage

The logging facade works uniformly across all Kodio targets: Android, iOS, macOS, JVM, JS, and Wasm. No platform-specific setup is required beyond calling configureLogging in your shared or platform entry point.

Last modified: 27 June 2026