Skip to content

Commit

Permalink
add readme. Fix kotlin versions
Browse files Browse the repository at this point in the history
  • Loading branch information
devindi committed May 27, 2020
1 parent ec4cd73 commit d408cd6
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 4 deletions.
102 changes: 102 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# Kalev

Kalev is a structured logger for JVM (Java, Kotlin etc)

The idea of `Kalev` is pretty similar to `Timber`. Library provides `Kalevipoeg` interface with which you may implement various behaviour for log entries reaction.

## Packages

`kalev-lib` provides pure JVM implementation. Doesn't cotains any implementation of `Kalevipoeg`
`kalev-android` contains bridge between Kalev and Android's log system. `PrintPoeg` format log entry as JSON string and print it to LogCat


## Usage

Two easy steps:

1. Add any `Kalevipoeg` instances you want on application start. In Android application `onCreate` is a mosst suetable place
2. Call Kalev's static methods everywhere throughout your app.

Check full Android sample at `sample` dir

### Fields

Kalev encourages careful, structured logging through logging fields instead of long, unparseable error messages. For example, instead of: `Log.e("Failed to send event %s to topic %s with key %d", userEvent, selectedTopic, eventKey)`, you should log the much more discoverable:

```kotlin
Kalev.with("event", userEvent)
.with("key", eventKey)
.with("topic", selectedTopic)
.e("Failed to send event")
```

Note, that `with` call is optional

### Level logging

Kalev provides 5 levels of logs: verbose, debug, info, warning and error.

```kotlin
Kalev.v("Fragment created")
Kalev.v(throwable, "Fragment wasn't added")

Kalev.d("User logged in")
Kalev.d(throwable, "User error")

Kalev.i("Added item to bucket")
Kalev.i(throwable, "Busket is full")

Kalev.w("Paying for order")
Kalev.w(throwable, "Failed to pay")

Kalev.e("Smth happens")
Kalev.e(throwable, "Smth happened")
```

### Entries

Besides the fields added with `with` some fields are automatically added to all logging events:

`severity` The logging level. E.g. `i`.
`timestamp` The timestamp when the entry was created.
`message` The logging message passed to {v, d, i, w, e} after the `with` call. E.g. `Failed to send event.`

## Gradle
Add this to your dependencies block.
```
implementation 'eu.bolt:kalev:1.0.0'
```

To use an android extension use this dependency instead:
```
implementation 'eu.bolt:kalev-android:1.0.0'
```

## Naming

Kaleva - also known as Kalevi or Kalev - and his sons are important heroic figures in Estonian, Finnish and Karelian mythology. [Wiki](https://en.wikipedia.org/wiki/Kalevi_(mythology))

## License
```
MIT License
Copyright (c) 2020 Bolt Technologies OÜ
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
```
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
buildscript {

ext.versions = [
'kotlin': '1.3.72'
]

repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
classpath 'com.vanniktech:gradle-maven-publish-plugin:0.9.0'
}
}
Expand Down
2 changes: 1 addition & 1 deletion kalev-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ android {

dependencies {
api project (':kalev-lib')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72"
implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}"
}
2 changes: 1 addition & 1 deletion kalev-lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ apply plugin: 'kotlin'
apply plugin: 'com.vanniktech.maven.publish'

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72"
implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}"
}
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ android {

dependencies {
implementation project (':kalev-android')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.72"
implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}"
}

0 comments on commit d408cd6

Please sign in to comment.