Print is a modern Kotlin Multiplatform logging library with built-in crash handling.
It provides a single API for structured logging across JVM, Android, iOS, Kotlin/Native, JavaScript, and WebAssembly, while automatically capturing uncaught exceptions, native crashes, coroutine failures, and browser errors.
- Console logging
- File logging
- Network logging
- Structured log events
- Configurable log levels
- Multiple logger outputs
- Custom logger implementations
Print automatically installs platform-specific crash handlers:
- Coroutine exceptions
- JVM uncaught thread exceptions
- Native signals (
SIGSEGV,SIGABRT,SIGFPE,SIGILL,SIGBUS) - Browser exceptions (
window.onerror,unhandledrejection) - iOS uncaught exceptions
Crash reports are automatically forwarded to every configured logger.
| Platform | Console | File | Network | SigNoz | Firebase | Crash Handling |
|---|---|---|---|---|---|---|
| Android | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| iOS | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Desktop JVM | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Desktop Native (Windows / Linux / macOS) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| JavaScript | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| WebAssembly | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
dependencies {
implementation("io.github.cheerwizard:print:<version>")
}Install Print once during application startup.
Everything executed inside the installation block is protected by Print's crash handlers.
Print.install(
logLevel = LogLevel.WARNING,
crashReportFilepath = "logs/crash-report.log",
loggers = setOf(
ConsoleLogger(),
FileLogger(filepath),
SignozLogger(host),
FirebaseLogger(clientId, secret, measurementId)
)
) {
// Application entry point
}After installation, logging is available globally:
Print.v("Renderer", "Renderer initialized")
Print.i("Game", "Game started")
Print.d("Assets", "Loading textures")
Print.w("Network", "Connection lost")
Print.e("Physics", "Simulation failed")
Print.f("Engine", "Fatal error")enum class LogLevel {
NONE,
VERBOSE,
INFO,
DEBUG,
WARNING,
ERROR,
FATAL
}The configured level acts as the global minimum severity. Events below it are ignored before reaching any logger.
Writes formatted logs to the platform console.
ConsoleLogger()Stores logs locally.
Crash reports are also written to the configured file.
On JavaScript and WebAssembly, IndexedDB is used when available.
FileLogger(
filepath = "/logs/application.log"
)Sends structured log events to a SigNoz endpoint.
SignozLogger(
host = "https://ingest.signoz.io"
)Uploads logs and crash information to Firebase Analytics / Crashlytics.
FirebaseLogger(
clientId = "...",
secret = "...",
measurementId = "G-XXXXXXXXXX"
)Create your own destination by implementing either Logger or NetworkLogger.
class MyLogger : Logger {
override fun log(
level: LogLevel,
tag: String,
message: String
) {
// custom implementation
}
}Crash handling is enabled automatically.
No additional configuration is required.
| Crash Source | Supported Platforms |
|---|---|
| Coroutine exceptions | All |
| Thread uncaught exceptions | JVM, Android |
| Native signals | Android, Desktop Native, Desktop JVM |
| Browser exceptions | JavaScript, WebAssembly |
| iOS uncaught exceptions | iOS |
Native signal handlers use async-signal-safe APIs to ensure crash reports are written before process termination whenever possible.
Unlike traditional logging libraries, Print combines:
- Cross-platform logging
- Multiple logging backends
- Automatic crash reporting
- Native crash handling
- Structured log routing
behind a single Kotlin Multiplatform API.
Licensed under the Apache License, Version 2.0.
See the LICENSE file for details.