Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

Logger and Tracker project

Maven Central

Overview

The project consists of two Kotlin Multiplatform (KMP) libraries: Logger and Tracker. The Logger library is designed for logging events with different severity levels. The Tracker library is used for tracking events across different platforms. Both libraries utilize a common codebase with platform-specific implementations to handle device-specific functionalities.

Project Structure

  • commonMain: Contains common code shared between platforms.
  • androidMain: Contains Android-specific implementations.
  • iosMain: Contains iOS-specific implementations.

Getting Started

Installation

The Logger is published on Maven Central. Add it to the common source set of a Kotlin Multiplatform module:

kotlin {
    sourceSets {
        commonMain.dependencies {
            implementation("io.github.cyrillrx:logger:<version>")
        }
    }
}

It targets Android, the JVM, iosArm64 and iosSimulatorArm64, and is built with the latest stable toolchain: a consumer aligns on it before adopting a release (ADR-001).

The Tracker is not published yet.

Building the Project

git clone https://github.com/cyrillrx/kmp-logger-tracker.git
cd kmp-logger-tracker
./gradlew build

Usage

Logger

Log.install(
    CompositeLogger(
        children = listOf(ConsoleChild(Severity.DEBUG, clickableLogs = true)),
        onChildError = { child, error -> println("$child failed: $error") },
    ),
)

Log.info("Sync") { "Something happened" }
Log.error("Sync", throwable = error, attributes = mapOf("item" to id)) { "Upload failed" }

A class can also receive a Logger and stay independent from the global Log facade; tests then pass a CompositeLogger holding a RamLogChild.

Tracker

Tracker.setupExceptionCatcher { t -> Log.error("Tracker", throwable = t) { "Caught exception" } }
Tracker.addChild(createTracker())

val event = TrackEvent("Event Name")
Tracker.track(event)

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages