slf4j-kotlin-extensions

Utilities to make working with slf4j Loggers from Kotlin more enjoyable.

License

License

Categories

Categories

Kotlin Languages SLF4J Application Layer Libs Logging
GroupId

GroupId

com.frimastudio
ArtifactId

ArtifactId

slf4j-kotlin-extensions
Last Version

Last Version

2.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

slf4j-kotlin-extensions
Utilities to make working with slf4j Loggers from Kotlin more enjoyable.
Project URL

Project URL

https://github.com/FrimaStudio/slf4j-kotlin-extensions
Source Code Management

Source Code Management

https://github.com/FrimaStudio/slf4j-kotlin-extensions

Download slf4j-kotlin-extensions

How to add to project

<!-- https://jarcasting.com/artifacts/com.frimastudio/slf4j-kotlin-extensions/ -->
<dependency>
    <groupId>com.frimastudio</groupId>
    <artifactId>slf4j-kotlin-extensions</artifactId>
    <version>2.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.frimastudio/slf4j-kotlin-extensions/
implementation 'com.frimastudio:slf4j-kotlin-extensions:2.0.0'
// https://jarcasting.com/artifacts/com.frimastudio/slf4j-kotlin-extensions/
implementation ("com.frimastudio:slf4j-kotlin-extensions:2.0.0")
'com.frimastudio:slf4j-kotlin-extensions:jar:2.0.0'
<dependency org="com.frimastudio" name="slf4j-kotlin-extensions" rev="2.0.0">
  <artifact name="slf4j-kotlin-extensions" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.frimastudio', module='slf4j-kotlin-extensions', version='2.0.0')
)
libraryDependencies += "com.frimastudio" % "slf4j-kotlin-extensions" % "2.0.0"
[com.frimastudio/slf4j-kotlin-extensions "2.0.0"]

Dependencies

test (5)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.2.21
org.jetbrains.kotlin : kotlin-reflect jar 1.2.21
junit : junit jar 4.12
com.nhaarman : mockito-kotlin jar 1.4.0
org.slf4j : slf4j-simple jar 1.7.25

Project Modules

There are no modules declared in this project.

slf4j-kotlin-extensions

Utilities to make working with slf4j Loggers from Kotlin more enjoyable.

Build Status

Lazy loggers

Contains 3 lazyLogger utilities to get Lazy<org.slf4j.Logger> instances:

class TheClass {
    // Lazy logger with KClass
    private val logger by lazyLogger(TheClass::class)

    // Lazy logger with Java class
    private val logger by lazyLogger(TheClass::class.java)

    // Lazy logger with name
    private val logger by lazyLogger("the-logger's-name")
}

org.slf4j.Logger extensions

Contains extensions to use Kotlin's string expansion feature in SLF4J loggers:

class TheClass {
    private val logger by lazyLogger(TheClass::class)
    private val marker by lazy { MarkerFactory.getMarker("the-marker") }

    fun doSomething(param: Int) {
        logger.debug {
            // This will NOT be called if debug logs are not enabled for the logger ('isDebugEnabled')
            "You can now use Kotlin's string expansion for your logs :: $param"
        }

        logger.trace(marker) {
            "Also works with markers :: $param"
        }

        try {
            // Do something risky here
        } catch (e: Throwable) {
            logger.error(e) {
                "You can also use the (String, Throwable) overloads :: $param"
            }
        }
    }
}

All log functions support the same features (markers, throwables) even if not specifically demonstrated in the above example.

Adding to your project

Although not specified as a dependency, you will need an SLF4J implementation and the Kotlin stdlib on your classpath.

Gradle

dependencies {
    compile 'com.frimastudio:slf4j-kotlin-extensions:VERSION'
}

Maven

<dependencies>
  <dependency>
    <groupId>com.frimastudio</groupId>
    <artifactId>slf4j-kotlin-extensions</artifactId>
    <version>VERSION</version>
  </dependency>
</dependencies>

Issues

Issues/requests should be entered in the project's issues page.


This project uses semantic versioning 2.0.0.

com.frimastudio

Frima Studio

We are a digital entertainment studio with a broad transmedia expertise. Designing and delivering fun, innovative experiences is our daily obsession.

Versions

Version
2.0.0
1.0.0