Step 1. Add the JitPack repository to your build file
Add it in your root settings.gradle at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
Add it in your settings.gradle.kts at the end of repositories:
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}
Add to pom.xml
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
Add it in your build.sbt at the end of resolvers:
resolvers += "jitpack" at "https://jitpack.io"
Add it in your project.clj at the end of repositories:
:repositories [["jitpack" "https://jitpack.io"]]
Step 2. Add the dependency
dependencies {
implementation 'com.github.vyasenenko:ktor-logger:1.1.2'
}
dependencies {
implementation("com.github.vyasenenko:ktor-logger:1.1.2")
}
<dependency>
<groupId>com.github.vyasenenko</groupId>
<artifactId>ktor-logger</artifactId>
<version>1.1.2</version>
</dependency>
libraryDependencies += "com.github.vyasenenko" % "ktor-logger" % "1.1.2"
:dependencies [[com.github.vyasenenko/ktor-logger "1.1.2"]]
Kotlin Wrapper 'org.slf4j:slf4j'
install(KLogger)
Use examples
Any().log { this.toString() }
Any().log { "$this" }
// back object with work
val date = Date().log { "Time in milliseconds: ${this.time}" }
// change log level
val any = Any().log(Level.DEBUG) { "$this" }
Output
INFO Application - java.lang.Object@6e6d7a4
INFO Application - java.lang.Object@6e6d7a4
INFO Application - Time in milliseconds: 1532348742345
DEBUG Application - java.lang.Object@6e6d7a4
val date = Date().logc { "{$it.BLUE}Time in milliseconds: ${this.time}" }
Output
INFO Application - [0;34mTime in milliseconds: 1532348742344