MFlisar/Lumberjack

Lumberjack - a customisable and extensible file/console logger (with optional Timber support)

★ 47Forks 5KotlinGitHub ↗Compare

Project website ↗

androidlogginglumberjacktimber

README

Maven Central API Kotlin Kotlin Multiplatform

Lumberjack

Platforms Android iOS Windows macOS WebAssembly

This library provides following main features:

  • simply lazy evalution based logger based on a L class for the shortest possible log codes
  • easily extendible with custom loggers
  • offers console and file logger implementations
  • supports log filtering
  • providers a viewer for log files

Table of Contents

📷 Screenshots

composeviewer

compose-viewer1 compose-viewer2

core

log1 log2

💻 Supported Platforms

Module android iOS windows macOS wasm Notes
core ✅ ✅ ✅ ✅ ✅ the core module of lumberjack
logger-console ✅ ✅ ✅ ✅ ✅ a console logger for lumberjack
logger-file ✅ ✅ ✅ ✅ ❌ a file logger for lumberjack
extension-composeviewer ✅ ✅ ✅ ✅ ✅ a compose viewer for lumberjack
extension-feedback ✅ ✅ ❌ ❌ ❌ a feedback module for lumberjack

➡️ Versions

Dependency Version
Kotlin 2.4.0
Jetbrains Compose 1.11.1
Jetbrains Compose Material3 1.9.0

⚠️ Following experimental annotations are used:

  • OptIn
    • androidx.compose.material3.ExperimentalMaterial3Api (3x)
    • kotlinx.cinterop.ExperimentalForeignApi (1x)

I try to use as less experimental features as possible, but in this case the ones above are needed!

🔧 Setup

Using Version Catalogs

Define the dependencies inside your libs.versions.toml file.

[versions]

lumberjack = "<LATEST-VERSION>"

[libraries]

lumberjack-core = { module = "io.github.mflisar.lumberjack:core", version.ref = "lumberjack" }
lumberjack-logger-console = { module = "io.github.mflisar.lumberjack:logger-console", version.ref = "lumberjack" }
lumberjack-logger-file = { module = "io.github.mflisar.lumberjack:logger-file", version.ref = "lumberjack" }
lumberjack-extension-composeviewer = { module = "io.github.mflisar.lumberjack:extension-composeviewer", version.ref = "lumberjack" }
lumberjack-extension-feedback = { module = "io.github.mflisar.lumberjack:extension-feedback", version.ref = "lumberjack" }

And then use the definitions in your projects build.gradle.kts file like following:

implementation(libs.lumberjack.core)
implementation(libs.lumberjack.logger.console)
implementation(libs.lumberjack.logger.file)
implementation(libs.lumberjack.extension.composeviewer)
implementation(libs.lumberjack.extension.feedback)
Direct Dependency Notation

Simply add the dependencies inside your build.gradle.kts file.

val lumberjack = "<LATEST-VERSION>"

implementation("io.github.mflisar.lumberjack:core:${lumberjack}")
implementation("io.github.mflisar.lumberjack:logger-console:${lumberjack}")
implementation("io.github.mflisar.lumberjack:logger-file:${lumberjack}")
implementation("io.github.mflisar.lumberjack:extension-composeviewer:${lumberjack}")
implementation("io.github.mflisar.lumberjack:extension-feedback:${lumberjack}")

🚀 Usage

1) Setup your loggers

// 1) register a console logger
L.plant(ConsoleLogger())

// 2) register a file logger
val setup = FileLoggerSetup.Daily(folder = FileLoggerSetup.getDefaultLogFolder())
// or one of the following setups
//val setup = FileLoggerSetup.FileSize(folder = FileLoggerSetup.getDefaultLogFolder())
//val setup = FileLoggerSetup.SingleFile(folder = FileLoggerSetup.getDefaultLogFolder())
L.plant(FileLogger(setup))

2) Start logging

L.d { "Some log" }
L.e(Exception("TEST")) { "Some log with exception" }
L.logIf { false }?.d {
    // this block will never be executed thanks to lazy evaluation
    "this log will never be printed nor will this block ever be executed"
}

// examples with tags and types
L.tag("Custom Tag").v { "Verbose log..." }
L.tag("Custom Tag").d { "Debug log..." }
L.tag("Custom Tag").i { "Info log..." }
L.tag("Custom Tag").w { "Warn log..." }
L.tag("Custom Tag").e { "Error log..." }
L.tag("Custom Tag").wtf { "WTF log..." }

📁 Modules

✨ Demo

A full demo is included inside the demo module, it shows nearly every usage with working examples.

ℹ️ More

📚 API

Check out the API documentation.

💡 Other Libraries

You can find more of my multiplatform libraries that work well together here.

🔀 Compatibility

When combining my libraries, you can find compatibility information here.

Contributors

MFlisarMFlisarWorkgithub-actions[bot]

Issues