diff --git a/src/commonMain/kotlin/io/github/oshai/kotlinlogging/KLogger.kt b/src/commonMain/kotlin/io/github/oshai/kotlinlogging/KLogger.kt index 2d8671e3..d8009c61 100644 --- a/src/commonMain/kotlin/io/github/oshai/kotlinlogging/KLogger.kt +++ b/src/commonMain/kotlin/io/github/oshai/kotlinlogging/KLogger.kt @@ -1,3 +1,5 @@ +@file:Suppress("MoveLambdaOutsideParentheses") + package io.github.oshai.kotlinlogging import io.github.oshai.kotlinlogging.internal.toStringSafe @@ -280,7 +282,8 @@ public interface KLogger { * * @param msg the message string to be logged */ - @Deprecated("Use trace {} instead") public fun trace(msg: String?): Unit = trace { msg } + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace { \"\$msg\"}")) + public fun trace(msg: String?): Unit = trace { msg } /** * Log a message at the TRACE level according to the specified msg and argument. @@ -290,7 +293,8 @@ public interface KLogger { * @param msg the msg string * @param arg the argument */ - @Deprecated("Use trace {} instead") public fun trace(msg: String?, arg: Any?): Unit = TODO() + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace { \"\$msg \$arg\"}")) + public fun trace(msg: String?, arg: Any?): Unit = TODO() /** * Log a message at the TRACE level according to the specified msg and arguments. @@ -301,7 +305,7 @@ public interface KLogger { * @param arg1 the first argument * @param arg2 the second argument */ - @Deprecated("Use trace {} instead") + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace { \"\$msg \$arg1 \$arg2\"}")) public fun trace(msg: String?, arg1: Any?, arg2: Any?): Unit = TODO() /** @@ -316,7 +320,7 @@ public interface KLogger { * @param msg the msg string * @param arguments a list of 3 or more arguments */ - @Deprecated("Use trace {} instead") + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace { \"\$msg \$arguments\"}")) public fun trace(msg: String?, vararg arguments: Any?): Unit = TODO() /** @@ -325,7 +329,7 @@ public interface KLogger { * @param msg the message accompanying the exception * @param t the exception (throwable) to log */ - @Deprecated("Use trace {} instead") + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace(t) { \"\$msg\"}")) public fun trace(msg: String?, t: Throwable?): Unit = trace(t as Throwable, null, { msg }) /** @@ -334,7 +338,7 @@ public interface KLogger { * @param marker the marker data specific to this log statement * @param msg the message string to be logged */ - @Deprecated("Use trace {} instead") + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace(marker) { \"\$msg\"}")) public fun trace(marker: Marker?, msg: String?): Unit = trace(null as Throwable?, marker, { msg }) /** @@ -345,7 +349,7 @@ public interface KLogger { * @param msg the msg string * @param arg the argument */ - @Deprecated("Use trace {} instead") + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace(marker) { \"\$msg \$arg\"}")) public fun trace(marker: Marker?, msg: String?, arg: Any?): Unit = TODO() /** @@ -357,7 +361,10 @@ public interface KLogger { * @param arg1 the first argument * @param arg2 the second argument */ - @Deprecated("Use trace {} instead") + @Deprecated( + "Use trace {} instead", + replaceWith = ReplaceWith("trace(marker) { \"\$msg \$arg1 \$arg2\"}") + ) public fun trace(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = TODO() /** @@ -368,7 +375,10 @@ public interface KLogger { * @param msg the msg string * @param arguments an array of arguments */ - @Deprecated("Use trace {} instead") + @Deprecated( + "Use trace {} instead", + replaceWith = ReplaceWith("trace(marker) { \"\$msg \$arguments\"}") + ) public fun trace(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = TODO() /** @@ -379,7 +389,7 @@ public interface KLogger { * @param msg the message accompanying the exception * @param t the exception (throwable) to log */ - @Deprecated("Use trace {} instead") + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace(t, marker) { \"\$msg\"}")) public fun trace(marker: Marker?, msg: String?, t: Throwable?): Unit = trace(t as Throwable, marker, { msg }) @@ -388,7 +398,8 @@ public interface KLogger { * * @param msg the message string to be logged */ - @Deprecated("Use debug {} instead") public fun debug(msg: String?): Unit = debug { msg } + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug { \"\$msg\"}")) + public fun debug(msg: String?): Unit = debug { msg } /** * Log a message at the DEBUG level according to the specified msg and argument. @@ -398,7 +409,8 @@ public interface KLogger { * @param msg the msg string * @param arg the argument */ - @Deprecated("Use debug {} instead") public fun debug(msg: String?, arg: Any?): Unit = TODO() + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug { \"\$msg \$arg\"}")) + public fun debug(msg: String?, arg: Any?): Unit = TODO() /** * Log a message at the DEBUG level according to the specified msg and arguments. @@ -409,7 +421,7 @@ public interface KLogger { * @param arg1 the first argument * @param arg2 the second argument */ - @Deprecated("Use debug {} instead") + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug { \"\$msg \$arg1 \$arg2\"}")) public fun debug(msg: String?, arg1: Any?, arg2: Any?): Unit = TODO() /** @@ -433,7 +445,7 @@ public interface KLogger { * @param msg the message accompanying the exception * @param t the exception (throwable) to log */ - @Deprecated("Use debug {} instead") + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug(t) { \"\$msg\"}")) public fun debug(msg: String?, t: Throwable?): Unit = debug(t as Throwable, null, { msg }) /** @@ -442,7 +454,7 @@ public interface KLogger { * @param marker the marker data specific to this log statement * @param msg the message string to be logged */ - @Deprecated("Use debug {} instead") + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug(marker) { \"\$msg\"}")) public fun debug(marker: Marker?, msg: String?): Unit = debug(null as Throwable?, marker, { msg }) /** @@ -453,7 +465,7 @@ public interface KLogger { * @param msg the msg string * @param arg the argument */ - @Deprecated("Use debug {} instead") + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug(marker) { \"\$msg \$arg\"}")) public fun debug(marker: Marker?, msg: String?, arg: Any?): Unit = TODO() /** @@ -465,7 +477,10 @@ public interface KLogger { * @param arg1 the first argument * @param arg2 the second argument */ - @Deprecated("Use debug {} instead") + @Deprecated( + "Use debug {} instead", + replaceWith = ReplaceWith("debug(marker) { \"\$msg \$arg1 \$arg2\"}") + ) public fun debug(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = TODO() /** @@ -476,7 +491,10 @@ public interface KLogger { * @param msg the msg string * @param arguments a list of 3 or more arguments */ - @Deprecated("Use debug {} instead") + @Deprecated( + "Use debug {} instead", + replaceWith = ReplaceWith("debug(marker) { \"\$msg \$arguments\"}") + ) public fun debug(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = TODO() /** @@ -487,7 +505,7 @@ public interface KLogger { * @param msg the message accompanying the exception * @param t the exception (throwable) to log */ - @Deprecated("Use debug {} instead") + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug(t, marker) { \"\$msg\"}")) public fun debug(marker: Marker?, msg: String?, t: Throwable?): Unit = debug(t as Throwable, marker, { msg }) @@ -506,7 +524,8 @@ public interface KLogger { * @param msg the msg string * @param arg the argument */ - @Deprecated("Use info {} instead") public fun info(msg: String?, arg: Any?): Unit = TODO() + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info { \"\$msg \$arg\"}")) + public fun info(msg: String?, arg: Any?): Unit = TODO() /** * Log a message at the INFO level according to the specified msg and arguments. @@ -517,7 +536,7 @@ public interface KLogger { * @param arg1 the first argument * @param arg2 the second argument */ - @Deprecated("Use info {} instead") + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info { \"\$msg \$arg1 \$arg2\"}")) public fun info(msg: String?, arg1: Any?, arg2: Any?): Unit = TODO() /** @@ -531,7 +550,7 @@ public interface KLogger { * @param msg the msg string * @param arguments a list of 3 or more arguments */ - @Deprecated("Use info {} instead") + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info { \"\$msg \$arguments\"}")) public fun info(msg: String?, vararg arguments: Any?): Unit = TODO() /** @@ -540,7 +559,7 @@ public interface KLogger { * @param msg the message accompanying the exception * @param t the exception (throwable) to log */ - @Deprecated("Use info {} instead") + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info(t) { \"\$msg\"}")) public fun info(msg: String?, t: Throwable?): Unit = info(t as Throwable, null, { msg }) /** @@ -549,7 +568,7 @@ public interface KLogger { * @param marker The marker specific to this log statement * @param msg the message string to be logged */ - @Deprecated("Use info {} instead") + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info(marker) { \"\$msg\"}")) public fun info(marker: Marker?, msg: String?): Unit = info(null as Throwable?, marker, { msg }) /** @@ -560,7 +579,7 @@ public interface KLogger { * @param msg the msg string * @param arg the argument */ - @Deprecated("Use info {} instead") + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info(marker) { \"\$msg \$arg\"}")) public fun info(marker: Marker?, msg: String?, arg: Any?): Unit = TODO() /** @@ -572,7 +591,10 @@ public interface KLogger { * @param arg1 the first argument * @param arg2 the second argument */ - @Deprecated("Use info {} instead") + @Deprecated( + "Use info {} instead", + replaceWith = ReplaceWith("info(marker) { \"\$msg \$arg1 \$arg2\"}") + ) public fun info(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = TODO() /** @@ -583,7 +605,10 @@ public interface KLogger { * @param msg the msg string * @param arguments a list of 3 or more arguments */ - @Deprecated("Use info {} instead") + @Deprecated( + "Use info {} instead", + replaceWith = ReplaceWith("info(marker) { \"\$msg \$arguments\"}") + ) public fun info(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = TODO() /** @@ -594,7 +619,7 @@ public interface KLogger { * @param msg the message accompanying the exception * @param t the exception (throwable) to log */ - @Deprecated("Use info {} instead") + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info(t, marker) { \"\$msg\"}")) public fun info(marker: Marker?, msg: String?, t: Throwable?): Unit = info(t as Throwable, marker, { msg }) @@ -613,7 +638,8 @@ public interface KLogger { * @param msg the msg string * @param arg the argument */ - @Deprecated("Use warn {} instead") public fun warn(msg: String?, arg: Any?): Unit = TODO() + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn { \"\$msg \$arg\"}")) + public fun warn(msg: String?, arg: Any?): Unit = TODO() /** * Log a message at the WARN level according to the specified msg and arguments. @@ -626,7 +652,7 @@ public interface KLogger { * @param msg the msg string * @param arguments a list of 3 or more arguments */ - @Deprecated("Use warn {} instead") + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn { \"\$msg \$arguments\"}")) public fun warn(msg: String?, vararg arguments: Any?): Unit = TODO() /** @@ -638,7 +664,7 @@ public interface KLogger { * @param arg1 the first argument * @param arg2 the second argument */ - @Deprecated("Use warn {} instead") + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn { \"\$msg \$arg1 \$arg2\"}")) public fun warn(msg: String?, arg1: Any?, arg2: Any?): Unit = TODO() /** @@ -647,7 +673,7 @@ public interface KLogger { * @param msg the message accompanying the exception * @param t the exception (throwable) to log */ - @Deprecated("Use warn {} instead") + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn(t) { \"\$msg\"}")) public fun warn(msg: String?, t: Throwable?): Unit = warn(t as Throwable, null, { msg }) /** @@ -656,7 +682,7 @@ public interface KLogger { * @param marker The marker specific to this log statement * @param msg the message string to be logged */ - @Deprecated("Use warn {} instead") + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn(marker) { \"\$msg\"}")) public fun warn(marker: Marker?, msg: String?): Unit = warn(null as Throwable?, marker, { msg }) /** @@ -667,7 +693,7 @@ public interface KLogger { * @param msg the msg string * @param arg the argument */ - @Deprecated("Use warn {} instead") + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn(marker) { \"\$msg \$arg\"}")) public fun warn(marker: Marker?, msg: String?, arg: Any?): Unit = TODO() /** @@ -679,6 +705,10 @@ public interface KLogger { * @param arg1 the first argument * @param arg2 the second argument */ + @Deprecated( + "Use warn {} instead", + replaceWith = ReplaceWith("warn(marker) { \"\$msg \$arg1 \$arg2\"}") + ) public fun warn(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = TODO() /** @@ -689,7 +719,10 @@ public interface KLogger { * @param msg the msg string * @param arguments a list of 3 or more arguments */ - @Deprecated("Use warn {} instead") + @Deprecated( + "Use warn {} instead", + replaceWith = ReplaceWith("warn(marker) { \"\$msg \$arguments\"}") + ) public fun warn(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = TODO() /** @@ -700,7 +733,7 @@ public interface KLogger { * @param msg the message accompanying the exception * @param t the exception (throwable) to log */ - @Deprecated("Use warn {} instead") + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn(t, marker) { \"\$msg\"}")) public fun warn(marker: Marker?, msg: String?, t: Throwable?): Unit = warn(t as Throwable, marker, { msg }) @@ -709,7 +742,8 @@ public interface KLogger { * * @param msg the message string to be logged */ - @Deprecated("Use error {} instead") public fun error(msg: String?): Unit = error { msg } + @Deprecated("Use error {} instead", replaceWith = ReplaceWith("error { \"\$msg\"}")) + public fun error(msg: String?): Unit = error { msg } /** * Log a message at the ERROR level according to the specified msg and argument. @@ -719,7 +753,8 @@ public interface KLogger { * @param msg the msg string * @param arg the argument */ - @Deprecated("Use error {} instead") public fun error(msg: String?, arg: Any?): Unit = TODO() + @Deprecated("Use error {} instead", replaceWith = ReplaceWith("error { \"\$msg \$arg\"}")) + public fun error(msg: String?, arg: Any?): Unit = TODO() /** * Log a message at the ERROR level according to the specified msg and arguments. @@ -730,7 +765,7 @@ public interface KLogger { * @param arg1 the first argument * @param arg2 the second argument */ - @Deprecated("Use error {} instead") + @Deprecated("Use error {} instead", replaceWith = ReplaceWith("error { \"\$msg \$arg1 \$arg2\"}")) public fun error(msg: String?, arg1: Any?, arg2: Any?): Unit = TODO() /** @@ -745,7 +780,7 @@ public interface KLogger { * @param msg the msg string * @param arguments a list of 3 or more arguments */ - @Deprecated("Use error {} instead") + @Deprecated("Use error {} instead", replaceWith = ReplaceWith("error { \"\$msg \$arguments\"}")) public fun error(msg: String?, vararg arguments: Any?): Unit = TODO() /** @@ -754,7 +789,7 @@ public interface KLogger { * @param msg the message accompanying the exception * @param t the exception (throwable) to log */ - @Deprecated("Use error(t){} instead") + @Deprecated("Use error(t){} instead", replaceWith = ReplaceWith("error(t) { \"\$msg\"}")) public fun error(msg: String?, t: Throwable?): Unit = error(t, null) { msg } /** @@ -763,7 +798,10 @@ public interface KLogger { * @param marker The marker specific to this log statement * @param msg the message string to be logged */ - @Deprecated("Use error(marker){} instead") + @Deprecated( + "Use error(marker){} instead", + replaceWith = ReplaceWith("error(marker) { \"\$msg\"}") + ) public fun error(marker: Marker?, msg: String?): Unit = error(null as Throwable?, marker) { msg } /** @@ -774,6 +812,10 @@ public interface KLogger { * @param msg the msg string * @param arg the argument */ + @Deprecated( + "Use error(marker){} instead", + replaceWith = ReplaceWith("error(marker) { \"\$msg \$arg \"}") + ) public fun error(marker: Marker?, msg: String?, arg: Any?): Unit = TODO() /** @@ -785,7 +827,10 @@ public interface KLogger { * @param arg1 the first argument * @param arg2 the second argument */ - @Deprecated("Use error(marker){} instead") + @Deprecated( + "Use error(marker){} instead", + replaceWith = ReplaceWith("error(marker) { \"\$msg \$arg1 \$arg2\"}") + ) public fun error(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = TODO() /** @@ -796,7 +841,10 @@ public interface KLogger { * @param msg the msg string * @param arguments a list of 3 or more arguments */ - @Deprecated("Use error(marker){} instead") + @Deprecated( + "Use error(marker){} instead", + replaceWith = ReplaceWith("error(marker) { \"\$msg \$arguments\"}") + ) public fun error(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = TODO() @Deprecated("Use error instead", ReplaceWith("error(t, marker, msg)")) diff --git a/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationAwareKLogger.kt b/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationAwareKLogger.kt index e8967704..3dbeec27 100644 --- a/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationAwareKLogger.kt +++ b/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationAwareKLogger.kt @@ -17,7 +17,7 @@ import org.slf4j.spi.LocationAwareLogger * correct fully qualified class name. */ internal class LocationAwareKLogger(override val underlyingLogger: LocationAwareLogger) : - KLogger, DelegatingKLogger, Slf4jLogger() { + KLogger, DelegatingKLogger, Slf4jLogger() { override val name: String get() = underlyingLogger.name diff --git a/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationIgnorantKLogger.kt b/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationIgnorantKLogger.kt index e1f853c0..c1115c81 100644 --- a/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationIgnorantKLogger.kt +++ b/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationIgnorantKLogger.kt @@ -14,7 +14,7 @@ import org.slf4j.Logger * methods */ internal class LocationIgnorantKLogger(override val underlyingLogger: Logger) : - KLogger, DelegatingKLogger, Slf4jLogger() { + KLogger, DelegatingKLogger, Slf4jLogger() { override val name: String get() = underlyingLogger.name diff --git a/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/Slf4jLogger.kt b/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/Slf4jLogger.kt index 227c302c..909fcdd5 100644 --- a/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/Slf4jLogger.kt +++ b/src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/Slf4jLogger.kt @@ -1,12 +1,13 @@ package io.github.oshai.kotlinlogging.slf4j.internal +import io.github.oshai.kotlinlogging.DelegatingKLogger import io.github.oshai.kotlinlogging.KLogger import io.github.oshai.kotlinlogging.Level import io.github.oshai.kotlinlogging.Marker import io.github.oshai.kotlinlogging.slf4j.toSlf4j import org.slf4j.Logger -public abstract class Slf4jLogger : KLogger { +public abstract class Slf4jLogger : KLogger, DelegatingKLogger { // we don't move more methods to here because if it will appear on stacktrace // it will break fqcn for class name in location aware loggers @@ -26,4 +27,132 @@ public abstract class Slf4jLogger : KLogger { Level.OFF -> false } } + + /// + /// The methods below are deprecated and will be removed in the future + /// + + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace { \"\$msg \$arg\"}")) + public override fun trace(msg: String?, arg: Any?): Unit = underlyingLogger.trace(msg, arg) + + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace { \"\$msg \$arg1 \$arg2\"}")) + public override fun trace(msg: String?, arg1: Any?, arg2: Any?): Unit = + underlyingLogger.trace(msg, arg1, arg2) + + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace { \"\$msg \$arguments\"}")) + public override fun trace(msg: String?, vararg arguments: Any?): Unit = + underlyingLogger.trace(msg, *arguments) + + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace { \"\$msg \$arg\"}")) + public override fun trace(marker: Marker?, msg: String?, arg: Any?): Unit = + underlyingLogger.trace(marker?.toSlf4j(), msg, arg) + + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace { \"\$msg \$arg1 \$arg2\"}")) + public override fun trace(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = + underlyingLogger.trace(marker?.toSlf4j(), msg, arg1, arg2) + + @Deprecated("Use trace {} instead", replaceWith = ReplaceWith("trace { \"\$msg \$arguments\"}")) + public override fun trace(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = + underlyingLogger.trace(marker?.toSlf4j(), msg, *arguments) + + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug { \"\$msg \$arg\"}")) + public override fun debug(msg: String?, arg: Any?): Unit = underlyingLogger.debug(msg, arg) + + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug { \"\$msg \$arg1 \$arg2\"}")) + public override fun debug(msg: String?, arg1: Any?, arg2: Any?): Unit = + underlyingLogger.debug(msg, arg1, arg2) + + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug { \"\$msg \$arguments\"}")) + public override fun debug(msg: String?, vararg arguments: Any?): Unit = + underlyingLogger.debug(msg, *arguments) + + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug { \"\$msg \$arg\"}")) + public override fun debug(marker: Marker?, msg: String?, arg: Any?): Unit = + underlyingLogger.debug(marker?.toSlf4j(), msg, arg) + + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug { \"\$msg \$arg1 \$arg2\"}")) + public override fun debug(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = + underlyingLogger.debug(marker?.toSlf4j(), msg, arg1, arg2) + + @Deprecated("Use debug {} instead", replaceWith = ReplaceWith("debug { \"\$msg \$arguments\"}")) + public override fun debug(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = + underlyingLogger.debug(marker?.toSlf4j(), msg, *arguments) + + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info { \"\$msg \$arg\"}")) + public override fun info(msg: String?, arg: Any?): Unit = underlyingLogger.info(msg, arg) + + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info { \"\$msg \$arg1 \$arg2\"}")) + public override fun info(msg: String?, arg1: Any?, arg2: Any?): Unit = + underlyingLogger.info(msg, arg1, arg2) + + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info { \"\$msg \$arguments\"}")) + public override fun info(msg: String?, vararg arguments: Any?): Unit = + underlyingLogger.info(msg, *arguments) + + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info { \"\$msg \$arg\"}")) + public override fun info(marker: Marker?, msg: String?, arg: Any?): Unit = + underlyingLogger.info(marker?.toSlf4j(), msg, arg) + + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info { \"\$msg \$arg1 \$arg2\"}")) + public override fun info(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = + underlyingLogger.info(marker?.toSlf4j(), msg, arg1, arg2) + + @Deprecated("Use info {} instead", replaceWith = ReplaceWith("info { \"\$msg \$arguments\"}")) + public override fun info(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = + underlyingLogger.info(marker?.toSlf4j(), msg, *arguments) + + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn { \"\$msg \$arg\"}")) + public override fun warn(msg: String?, arg: Any?): Unit = underlyingLogger.warn(msg, arg) + + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn { \"\$msg \$arg1 \$arg2\"}")) + public override fun warn(msg: String?, vararg arguments: Any?): Unit = + underlyingLogger.warn(msg, *arguments) + + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn { \"\$msg \$arg1 \$arg2\"}")) + public override fun warn(msg: String?, arg1: Any?, arg2: Any?): Unit = + underlyingLogger.warn(msg, arg1, arg2) + + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn { \"\$msg \$arg\"}")) + public override fun warn(marker: Marker?, msg: String?, arg: Any?): Unit = + underlyingLogger.warn(marker?.toSlf4j(), msg, arg) + + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn { \"\$msg \$arg1 \$arg2\"}")) + public override fun warn(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = + underlyingLogger.warn(marker?.toSlf4j(), msg, arg1, arg2) + + @Deprecated("Use warn {} instead", replaceWith = ReplaceWith("warn { \"\$msg \$arguments\"}")) + public override fun warn(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = + underlyingLogger.warn(marker?.toSlf4j(), msg, *arguments) + + @Deprecated("Use error {} instead", replaceWith = ReplaceWith("error { \"\$msg \$arg\"}")) + public override fun error(msg: String?, arg: Any?): Unit = underlyingLogger.error(msg, arg) + + @Deprecated("Use error {} instead", replaceWith = ReplaceWith("error { \"\$msg \$arg1 \$arg2\"}")) + public override fun error(msg: String?, arg1: Any?, arg2: Any?): Unit = + underlyingLogger.error(msg, arg1, arg2) + + @Deprecated("Use error {} instead", replaceWith = ReplaceWith("error { \"\$msg \$arguments\"}")) + public override fun error(msg: String?, vararg arguments: Any?): Unit = + underlyingLogger.error(msg, *arguments) + + @Deprecated( + "Use error(marker){} instead", + replaceWith = ReplaceWith("error(marker){ \"\$msg \$arg\"}") + ) + public override fun error(marker: Marker?, msg: String?, arg: Any?): Unit = + underlyingLogger.error(marker?.toSlf4j(), msg, arg) + + @Deprecated( + "Use error(marker){} instead", + replaceWith = ReplaceWith("error(marker){ \"\$msg \$arg1 \$arg2\"}") + ) + public override fun error(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = + underlyingLogger.error(marker?.toSlf4j(), msg, arg1, arg2) + + @Deprecated( + "Use error(marker){} instead", + replaceWith = ReplaceWith("error(marker){ \"\$msg \$arguments\"}") + ) + public override fun error(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = + underlyingLogger.error(marker?.toSlf4j(), msg, *arguments) } diff --git a/src/jvmMain/kotlin/io/github/oshai/kotlinlogging/KLogging.kt b/src/jvmMain/kotlin/io/github/oshai/kotlinlogging/KLogging.kt new file mode 100644 index 00000000..27091edd --- /dev/null +++ b/src/jvmMain/kotlin/io/github/oshai/kotlinlogging/KLogging.kt @@ -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) +}