slf4j-lambda-core

slf4j-lambda

License

License

Categories

Categories

SLF4J Application Layer Libs Logging
GroupId

GroupId

kr.pe.kwonnam.slf4j-lambda
ArtifactId

ArtifactId

slf4j-lambda-core
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

slf4j-lambda-core
slf4j-lambda
Project URL

Project URL

https://github.com/kwon37xi/slf4j-lambda
Source Code Management

Source Code Management

https://github.com/kwon37xi/slf4j-lambda

Download slf4j-lambda-core

How to add to project

<!-- https://jarcasting.com/artifacts/kr.pe.kwonnam.slf4j-lambda/slf4j-lambda-core/ -->
<dependency>
    <groupId>kr.pe.kwonnam.slf4j-lambda</groupId>
    <artifactId>slf4j-lambda-core</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/kr.pe.kwonnam.slf4j-lambda/slf4j-lambda-core/
implementation 'kr.pe.kwonnam.slf4j-lambda:slf4j-lambda-core:0.1'
// https://jarcasting.com/artifacts/kr.pe.kwonnam.slf4j-lambda/slf4j-lambda-core/
implementation ("kr.pe.kwonnam.slf4j-lambda:slf4j-lambda-core:0.1")
'kr.pe.kwonnam.slf4j-lambda:slf4j-lambda-core:jar:0.1'
<dependency org="kr.pe.kwonnam.slf4j-lambda" name="slf4j-lambda-core" rev="0.1">
  <artifact name="slf4j-lambda-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='kr.pe.kwonnam.slf4j-lambda', module='slf4j-lambda-core', version='0.1')
)
libraryDependencies += "kr.pe.kwonnam.slf4j-lambda" % "slf4j-lambda-core" % "0.1"
[kr.pe.kwonnam.slf4j-lambda/slf4j-lambda-core "0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.24

test (5)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest-core jar 1.3
org.hamcrest : hamcrest-library jar 1.3
org.mockito : mockito-all jar 1.10.19
org.assertj : assertj-core jar 3.8.0

Project Modules

There are no modules declared in this project.

Slf4j-Lambda

Maven Central

Slf4j logging with Java 8 lambda expressions.

The lambda expressions are evaluated only when the log level is enabled.

Requirements

  • Java 8
  • Slf4j API

Dependencies

dependencies {
    compile 'kr.pe.kwonnam.slf4j:slf4j-lambda-core:0.1'
}

Usages

  • Use LambdaLoggerFactory instread of Slf4j's LoggerFactory
  • Use LambdaLogger instead of Slf4j's Logger. LambdaLogger inherits Logger, so you can still use all Logger's logging methods with lambda supporting logging methods.
import kr.pe.kwonnam.slf4jlambda.LambdaLogger;
import kr.pe.kwonnam.slf4jlambda.LambdaLoggerFactory;

LambdaLogger log = LambdaLoggerFactory.getLogger(YourClass.class);

// lambda for message itself
log.debug(() -> createMessage("debug level"));

// lambda for message format's arguments
log.info("info lambda formatter number {}, string {}", () -> 123, () -> "Hello LambdaLogger");

// method reference
public String longRunnigMethod() {
    return "some long running method";
}

log.debug("Long running method logging {}", this::longRunnigMethod);

// exception logging
log.error(() -> "error lambda exception msg - " + ex.getMessage(), ex);

Versions

Version
0.1