Skip to content

CheerWizard/Print

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Print

Maven Central Kotlin License

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.


Features

Logging

  • Console logging
  • File logging
  • Network logging
  • Structured log events
  • Configurable log levels
  • Multiple logger outputs
  • Custom logger implementations

Crash Handling

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 Support

Platform Console File Network SigNoz Firebase Crash Handling
Android
iOS
Desktop JVM
Desktop Native (Windows / Linux / macOS)
JavaScript
WebAssembly

Installation

dependencies {
    implementation("io.github.cheerwizard:print:<version>")
}

Quick Start

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")

Log Levels

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.


Available Loggers

ConsoleLogger

Writes formatted logs to the platform console.

ConsoleLogger()

FileLogger

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"
)

SigNozLogger

Sends structured log events to a SigNoz endpoint.

SignozLogger(
    host = "https://ingest.signoz.io"
)

FirebaseLogger

Uploads logs and crash information to Firebase Analytics / Crashlytics.

FirebaseLogger(
    clientId = "...",
    secret = "...",
    measurementId = "G-XXXXXXXXXX"
)

Custom Logger

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

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.


Why Print?

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.


License

Licensed under the Apache License, Version 2.0.

See the LICENSE file for details.

About

A simple cross platform logging library for KMP projects. Supports following platform targets: Android, iOS, Desktop JVM, Desktop Native (mingw, posix, linux), Web (JS, WasmJS).

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages