org.yggd:kotlin-loginitializer

Simplification for importing java logging APIs as Kotlin value.

License

License

Categories

Categories

Kotlin Languages
GroupId

GroupId

org.yggd
ArtifactId

ArtifactId

kotlin-loginitializer
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

org.yggd:kotlin-loginitializer
Simplification for importing java logging APIs as Kotlin value.
Project URL

Project URL

https://github.com/yggd/loginitializer
Source Code Management

Source Code Management

https://github.com/yggd/loginitializer

Download kotlin-loginitializer

How to add to project

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

Dependencies

compile (1)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-stdlib jar 1.0.2

provided (3)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.13
commons-logging : commons-logging jar 1.2
log4j : log4j jar 1.2.17

test (4)

Group / Artifact Type Version
uk.org.lidalia : slf4j-test jar 1.1.0
junit : junit jar 4.12
org.mockito : mockito-core jar 1.10.19
org.hamcrest : hamcrest-core jar 1.3

Project Modules

There are no modules declared in this project.

Apache license

loginitializer

This is the small library importing Java logging APIs (SLF4j, Apache commons-logging and Log4J).

Motivation

Groovy has implicit logging field injections with some simple annotation, as below.

@Grab(group='org.slf4j', module='slf4j-api', version='1.7.21')
import org.slf4j.*
import groovy.util.logging.Slf4j

@Slf4j
class LogstuffOnGroovy {
    def foo() {
      log.info "Hello, foo."
    }
}

But Kotlin, using logging APIs bother to you (a little).

import org.slf4j.LoggerFactory

class LogstuffOnKotlin {
    companion object {
        val logger = LoggerFactory.getLogger(LogstuffOnKotlin::class.java)
    }

    fun foo() {
        logger.info("Hello, foo.")
    }
}

How to use

replace companion object block as below.

class LogstuffOnKotlin {

    val logger = forSlf4j()

    fun foo() {
        logger.info("Hello, foo.")
    }
}

Install

To add this product to your project, the first thing to is to add in the API.

maven:

<dependency>
  <groupId>org.yggd</groupId>
  <artifactId>kotlin-loginitializer</artifactId>
  <version>1.0</version>
</dependency>

<!-- logging APIs you want.-->
<dependency>
  <groupId>org.slf4j</groupId>
  <artifactId>slf4j-api</artifactId>
  <version>${slf4j.version}</version>
  <scope>runtime</scope>
</dependency>

gradle:

repositories {
  mavenCentral()
}

dependencies {
  compile group: 'org.yggd', name: 'kotlin-loginitializer', version: '1.0'
  runtime group: 'commons-logging', name: 'commons-logging', version: '1.2' // logging APIs you want.
}

Versions

Version
1.0