-
-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
src/jvmMain/kotlin/io/github/oshai/kotlinlogging/KLogging.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |