Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paulwoitaschek/slimber
Built upon Timber. Without performance penality.
https://github.com/paulwoitaschek/slimber
android kotlin logging timber
Last synced: 12 days ago
JSON representation
Built upon Timber. Without performance penality.
- Host: GitHub
- URL: https://github.com/paulwoitaschek/slimber
- Owner: PaulWoitaschek
- License: apache-2.0
- Created: 2016-02-20T18:20:59.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2023-03-04T03:26:10.000Z (over 1 year ago)
- Last Synced: 2024-10-15T22:11:49.677Z (23 days ago)
- Topics: android, kotlin, logging, timber
- Language: Kotlin
- Homepage:
- Size: 246 KB
- Stars: 123
- Watchers: 3
- Forks: 8
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Slimber - Zero overhead Logging with Timber
Timber is a great library that makes logging very easy. However traditional logging like
```kotlin
if (BuildConfig.DEBUG) {
Log.d(TAG, expensiveToStringObject.toString())
}
```has one big advantage: The whole block will only be executed when you are in debug mode. If you pass anything to Timber, the String itself
and the precalculations will be created. Even if you never planted a tree.And this is where Slimber comes into play: It uses [Kotlin](https://kotlinlang.org/)s `inline`
capabilities so we can archieve the **no-cost-effect** because the whole block is executed only when there are trees planted. And remember:
In Kotlin you can specify the last function in an arugment of a function outside the parentheses.So you can do it like this:
```kotlin
d { "onCreate called with $expensiveToStringObject" }
```There are also functions that take a throwable as the first paramter, so you can use them like
```kotlin
e(throwable) { "there was a severe error" }
```Besides from that just use Timber for planting trees like you normally do
```kotlin
Timber.plant(DebugTree())
```# Installation
Add this to your root `settings.gradle.kts`
```kotlin
dependencyResolutionManagement {
repositories {
maven("https://jitpack.io")
}
}
```And then this dependency to your project:
```kotlin
dependencies {
implementation("com.github.PaulWoitaschek:Slimber:x.y.z")
}
```