Skip to content

Commit

Permalink
add back KLogging
Browse files Browse the repository at this point in the history
  • Loading branch information
oshai committed Jul 12, 2023
1 parent 84adc25 commit ce5bf15
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/jvmMain/kotlin/io/github/oshai/kotlinlogging/KLogging.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package io.github.oshai.kotlinlogging

import io.github.oshai.kotlinlogging.internal.KLoggerFactory

/**
* A class with logging capabilities usage example:
* ```
* class ClassWithLogging {
* companion object: KLogging()
* fun test() {
* logger.info{"test ClassWithLogging"}
* }
* }
* ```
*/
@Deprecated("Use KLogger instead", ReplaceWith("KLogger", "io.github.oshai.kotlinlogging.KLogger"))
public open class KLogging : KLoggable {
override val logger: KLogger = logger()
}

/** A class with logging capabilities and explicit logger name */
@Deprecated("Use KLogger instead", ReplaceWith("KLogger", "io.github.oshai.kotlinlogging.KLogger"))
public open class NamedKLogging(name: String) : KLoggable {
override val logger: KLogger = logger(name)
}

/**
* An interface representing class with logging capabilities implemented using a logger obtain a
* logger with logger() method
*/
@Deprecated("Use KLogger instead", ReplaceWith("KLogger", "io.github.oshai.kotlinlogging.KLogger"))
public interface KLoggable {

/** The member that performs the actual logging */
public val logger: KLogger

/** get logger for the class */
public fun logger(): KLogger = KLoggerFactory.logger(this::class.java.name)

/** get logger by explicit name */
public fun logger(name: String): KLogger = KLoggerFactory.logger(name)
}

0 comments on commit ce5bf15

Please sign in to comment.