Skip to content

Highly configurable, type-safe logging library for Kotlin/Multiplatform

License

Notifications You must be signed in to change notification settings

Micha-ohne-el/logbook

Repository files navigation

Kotlin 1.9.21 Maven Central CI status badge CD status badge Documentation available License – MIT

logbook

Kotlin/Multiplatform logging library.

Installation

Simply add a dependency on logbook to your Gradle project:

repositories {
    mavenCentral()
}

// for Kotlin/Multiplatform projects:
kotlin {
    sourceSets {
        commonMain.configure {
            dependencies {
                implementation("moe.micha:logbook:$version")
            }
        }
    }
}

// for Kotlin/JVM projects:
kotlin {
    dependencies {
        implementation("moe.micha:logbook:$version")
    }
}

Replace $version with the version you want, a list of which can be retrieved on Maven Central.

Contributing

I would love for people to contribute to logbook!

If you feel like the library is missing something or you've encountered a bug, please let me know with a GitHub Issue! No need to be shy, there is no format to these Issues, just type whatever you want :)

If you've already got experience with Kotlin, feel free to work on a fix or feature on your own and submitting a Pull Request! There are no official contribution guidelines, just try your best and I'll see if I can fix some issues if there are any :)

To Do

  • Handle multi-line log messages (such as stack traces).
  • Improve timestamp formatting by using Chunks as well.
    • Extend Chunks to be able to have a min and max width, padding, alignment, etc.
    • Also support relative timestamp (relative to the start of the program or to the last log message, etc.)
  • Add some sort of grouping mechanism (such as JavaScript's console.group).
    • Maybe provide two separate functions – groupImplicitly and groupExplicitly. groupExplicitly would take a block in which a sublogger is accessible, which prints to the group. groupImplicitly would cause all following calls to the logger to be treated as though they were done on a sublogger. Just some ideas.
  • Add a simple file outlet.
    • Add option to either append to existing file or clear file on every boot.
  • Add a rotating file outlet.