Skip to content

Commit 17d55a6

Browse files
mleweoshai
authored andcommitted
Upgrade ktfmt to version 0.47
1 parent 41dcc10 commit 17d55a6

File tree

24 files changed

+68
-59
lines changed

24 files changed

+68
-59
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ tasks {
261261
spotless {
262262
kotlin {
263263
target("src/**/*.kt")
264-
ktfmt("0.24").googleStyle()
264+
ktfmt("0.47").googleStyle()
265265
}
266266
}
267267

src/commonMain/kotlin/io/github/oshai/kotlinlogging/KLogger.kt

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public interface KLogger {
1414

1515
/**
1616
* Return the name of this `Logger` instance.
17+
*
1718
* @return name of this logger instance
1819
*/
1920
public val name: String
@@ -378,7 +379,7 @@ public interface KLogger {
378379
*/
379380
@Deprecated(
380381
"Use trace {} instead",
381-
replaceWith = ReplaceWith("trace(marker) { \"\$msg \$arg1 \$arg2\"}")
382+
replaceWith = ReplaceWith("trace(marker) { \"\$msg \$arg1 \$arg2\"}"),
382383
)
383384
public fun trace(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = TODO()
384385

@@ -392,7 +393,7 @@ public interface KLogger {
392393
*/
393394
@Deprecated(
394395
"Use trace {} instead",
395-
replaceWith = ReplaceWith("trace(marker) { \"\$msg \$arguments\"}")
396+
replaceWith = ReplaceWith("trace(marker) { \"\$msg \$arguments\"}"),
396397
)
397398
public fun trace(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = TODO()
398399

@@ -494,7 +495,7 @@ public interface KLogger {
494495
*/
495496
@Deprecated(
496497
"Use debug {} instead",
497-
replaceWith = ReplaceWith("debug(marker) { \"\$msg \$arg1 \$arg2\"}")
498+
replaceWith = ReplaceWith("debug(marker) { \"\$msg \$arg1 \$arg2\"}"),
498499
)
499500
public fun debug(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = TODO()
500501

@@ -508,7 +509,7 @@ public interface KLogger {
508509
*/
509510
@Deprecated(
510511
"Use debug {} instead",
511-
replaceWith = ReplaceWith("debug(marker) { \"\$msg \$arguments\"}")
512+
replaceWith = ReplaceWith("debug(marker) { \"\$msg \$arguments\"}"),
512513
)
513514
public fun debug(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = TODO()
514515

@@ -609,7 +610,7 @@ public interface KLogger {
609610
*/
610611
@Deprecated(
611612
"Use info {} instead",
612-
replaceWith = ReplaceWith("info(marker) { \"\$msg \$arg1 \$arg2\"}")
613+
replaceWith = ReplaceWith("info(marker) { \"\$msg \$arg1 \$arg2\"}"),
613614
)
614615
public fun info(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = TODO()
615616

@@ -623,7 +624,7 @@ public interface KLogger {
623624
*/
624625
@Deprecated(
625626
"Use info {} instead",
626-
replaceWith = ReplaceWith("info(marker) { \"\$msg \$arguments\"}")
627+
replaceWith = ReplaceWith("info(marker) { \"\$msg \$arguments\"}"),
627628
)
628629
public fun info(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = TODO()
629630

@@ -724,7 +725,7 @@ public interface KLogger {
724725
*/
725726
@Deprecated(
726727
"Use warn {} instead",
727-
replaceWith = ReplaceWith("warn(marker) { \"\$msg \$arg1 \$arg2\"}")
728+
replaceWith = ReplaceWith("warn(marker) { \"\$msg \$arg1 \$arg2\"}"),
728729
)
729730
public fun warn(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = TODO()
730731

@@ -738,7 +739,7 @@ public interface KLogger {
738739
*/
739740
@Deprecated(
740741
"Use warn {} instead",
741-
replaceWith = ReplaceWith("warn(marker) { \"\$msg \$arguments\"}")
742+
replaceWith = ReplaceWith("warn(marker) { \"\$msg \$arguments\"}"),
742743
)
743744
public fun warn(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = TODO()
744745

@@ -817,7 +818,7 @@ public interface KLogger {
817818
*/
818819
@Deprecated(
819820
"Use error(marker){} instead",
820-
replaceWith = ReplaceWith("error(marker) { \"\$msg\"}")
821+
replaceWith = ReplaceWith("error(marker) { \"\$msg\"}"),
821822
)
822823
public fun error(marker: Marker?, msg: String?): Unit = error(null as Throwable?, marker) { msg }
823824

@@ -831,7 +832,7 @@ public interface KLogger {
831832
*/
832833
@Deprecated(
833834
"Use error(marker){} instead",
834-
replaceWith = ReplaceWith("error(marker) { \"\$msg \$arg \"}")
835+
replaceWith = ReplaceWith("error(marker) { \"\$msg \$arg \"}"),
835836
)
836837
public fun error(marker: Marker?, msg: String?, arg: Any?): Unit = TODO()
837838

@@ -846,7 +847,7 @@ public interface KLogger {
846847
*/
847848
@Deprecated(
848849
"Use error(marker){} instead",
849-
replaceWith = ReplaceWith("error(marker) { \"\$msg \$arg1 \$arg2\"}")
850+
replaceWith = ReplaceWith("error(marker) { \"\$msg \$arg1 \$arg2\"}"),
850851
)
851852
public fun error(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit = TODO()
852853

@@ -860,7 +861,7 @@ public interface KLogger {
860861
*/
861862
@Deprecated(
862863
"Use error(marker){} instead",
863-
replaceWith = ReplaceWith("error(marker) { \"\$msg \$arguments\"}")
864+
replaceWith = ReplaceWith("error(marker) { \"\$msg \$arguments\"}"),
864865
)
865866
public fun error(marker: Marker?, msg: String?, vararg arguments: Any?): Unit = TODO()
866867

src/commonMain/kotlin/io/github/oshai/kotlinlogging/KotlinLogging.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public object KotlinLogging {
1717
* ```
1818
* private val logger = KotlinLogging.logger("io.github.oshai.kotlinlogging.MyLogger")
1919
* ```
20+
*
2021
* In most cases the name represents the package notation of the file that the logger is defined
2122
* in.
2223
*/

src/darwinMain/kotlin/io/github/oshai/kotlinlogging/DarwinKLogger.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class DarwinKLogger(override val name: String, override val underlyingLog
3535
__dso_handle.ptr,
3636
underlyingLogger,
3737
level.toDarwinLevel(),
38-
formattedMessage
38+
formattedMessage,
3939
)
4040
}
4141
}

src/darwinMain/kotlin/io/github/oshai/kotlinlogging/internal/KLoggerFactory.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal actual object KLoggerFactory {
3131
name.contains(".") -> {
3232
DarwinKLogger(
3333
name,
34-
os_log_create(name.substringBeforeLast("."), name.substringAfterLast("."))
34+
os_log_create(name.substringBeforeLast("."), name.substringAfterLast(".")),
3535
)
3636
}
3737
else -> {

src/directMain/kotlin/io/github/oshai/kotlinlogging/Appender.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ public interface Appender {
66

77
public abstract class FormattingAppender : Appender {
88
public abstract fun logFormattedMessage(loggingEvent: KLoggingEvent, formattedMessage: Any?)
9+
910
override fun log(loggingEvent: KLoggingEvent) {
1011
KotlinLoggingConfiguration.formatter.formatMessage(loggingEvent).let {
1112
logFormattedMessage(loggingEvent, it)

src/directMain/kotlin/io/github/oshai/kotlinlogging/KLoggingEvent.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public data class KLoggingEvent(
1212
level: Level,
1313
marker: Marker?,
1414
loggerName: String,
15-
eventBuilder: KLoggingEventBuilder
15+
eventBuilder: KLoggingEventBuilder,
1616
) : this(
1717
level,
1818
marker,
1919
loggerName,
2020
eventBuilder.message,
2121
eventBuilder.cause,
22-
eventBuilder.payload
22+
eventBuilder.payload,
2323
)
2424
}

src/javaMain/kotlin/io/github/oshai/kotlinlogging/internal/KLoggerNameResolver.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ internal actual object KLoggerNameResolver {
3636
// to search for the target declared field.
3737
null
3838
}
39-
}
40-
?: clazz
39+
} ?: clazz
4140
}
4241
}

src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationAwareKLogger.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ internal class LocationAwareKLogger(override val underlyingLogger: LocationAware
3737
override fun isLoggingEnabledFor(level: Level, marker: Marker?): Boolean {
3838
return isLoggingEnabledFor(underlyingLogger, level, marker)
3939
}
40+
4041
override fun at(level: Level, marker: Marker?, block: KLoggingEventBuilder.() -> Unit) {
4142
if (isLoggingEnabledFor(level, marker)) {
4243
KLoggingEventBuilder().apply(block).run {
@@ -52,7 +53,7 @@ internal class LocationAwareKLogger(override val underlyingLogger: LocationAware
5253
private fun logWithPayload(
5354
kLoggingEventBuilder: KLoggingEventBuilder,
5455
level: Level,
55-
marker: Marker?
56+
marker: Marker?,
5657
) {
5758
val builder = underlyingLogger.atLevel(level.toSlf4j())
5859
marker?.toSlf4j()?.let { builder.addMarker(it) }
@@ -67,15 +68,15 @@ internal class LocationAwareKLogger(override val underlyingLogger: LocationAware
6768
private fun logWithoutPayload(
6869
kLoggingEventBuilder: KLoggingEventBuilder,
6970
level: Level,
70-
marker: Marker?
71+
marker: Marker?,
7172
) {
7273
underlyingLogger.log(
7374
marker?.toSlf4j(),
7475
fqcn,
7576
level.toSlf4j().toInt(),
7677
kLoggingEventBuilder.message,
7778
null,
78-
kLoggingEventBuilder.cause
79+
kLoggingEventBuilder.cause,
7980
)
8081
}
8182

@@ -158,7 +159,7 @@ internal class LocationAwareKLogger(override val underlyingLogger: LocationAware
158159
EventConstants.TRACE_INT,
159160
tp.message,
160161
arrayOf<Any?>(result),
161-
tp.throwable
162+
tp.throwable,
162163
)
163164
}
164165
return result

src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/LocationIgnorantKLogger.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal class LocationIgnorantKLogger(override val underlyingLogger: Logger) :
3838
private fun logWithPayload(
3939
kLoggingEventBuilder: KLoggingEventBuilder,
4040
level: Level,
41-
marker: Marker?
41+
marker: Marker?,
4242
) {
4343
val builder = underlyingLogger.atLevel(level.toSlf4j())
4444
marker?.toSlf4j()?.let { builder.addMarker(it) }
@@ -50,7 +50,7 @@ internal class LocationIgnorantKLogger(override val underlyingLogger: Logger) :
5050
private fun logWithoutPayload(
5151
kLoggingEventBuilder: KLoggingEventBuilder,
5252
level: Level,
53-
marker: Marker?
53+
marker: Marker?,
5454
) {
5555
val slf4jMarker = marker?.toSlf4j()
5656
val message = kLoggingEventBuilder.message

src/javaMain/kotlin/io/github/oshai/kotlinlogging/slf4j/internal/Slf4jLogger.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public abstract class Slf4jLogger<T : Logger> : KLogger, DelegatingKLogger<T> {
1616
protected fun isLoggingEnabledFor(
1717
underlyingLogger: Logger,
1818
level: Level,
19-
marker: Marker?
19+
marker: Marker?,
2020
): Boolean {
2121
return when (level) {
2222
Level.TRACE -> underlyingLogger.isTraceEnabled(marker?.toSlf4j())
@@ -137,21 +137,21 @@ public abstract class Slf4jLogger<T : Logger> : KLogger, DelegatingKLogger<T> {
137137

138138
@Deprecated(
139139
"Use error(marker){} instead",
140-
replaceWith = ReplaceWith("error(marker){ \"\$msg \$arg\"}")
140+
replaceWith = ReplaceWith("error(marker){ \"\$msg \$arg\"}"),
141141
)
142142
public override fun error(marker: Marker?, msg: String?, arg: Any?): Unit =
143143
underlyingLogger.error(marker?.toSlf4j(), msg, arg)
144144

145145
@Deprecated(
146146
"Use error(marker){} instead",
147-
replaceWith = ReplaceWith("error(marker){ \"\$msg \$arg1 \$arg2\"}")
147+
replaceWith = ReplaceWith("error(marker){ \"\$msg \$arg1 \$arg2\"}"),
148148
)
149149
public override fun error(marker: Marker?, msg: String?, arg1: Any?, arg2: Any?): Unit =
150150
underlyingLogger.error(marker?.toSlf4j(), msg, arg1, arg2)
151151

152152
@Deprecated(
153153
"Use error(marker){} instead",
154-
replaceWith = ReplaceWith("error(marker){ \"\$msg \$arguments\"}")
154+
replaceWith = ReplaceWith("error(marker){ \"\$msg \$arguments\"}"),
155155
)
156156
public override fun error(marker: Marker?, msg: String?, vararg arguments: Any?): Unit =
157157
underlyingLogger.error(marker?.toSlf4j(), msg, *arguments)

src/jsMain/kotlin/io/github/oshai/kotlinlogging/KotlinLogging.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import kotlin.reflect.KProperty
55

66
/**
77
* The JS way to define a logger without explicit name
8+
*
89
* ```
910
* class MyClass {
1011
* private val logger by KotlinLogging.logger()
@@ -21,8 +22,7 @@ private class LoggerDelegate : ReadOnlyProperty<Any?, KLogger> {
2122
logger =
2223
thisRef.asDynamic()?.constructor?.name.unsafeCast<String?>()?.let {
2324
KotlinLogging.logger(it)
24-
}
25-
?: KotlinLogging.logger("root-logger")
25+
} ?: KotlinLogging.logger("root-logger")
2626
}
2727
return logger
2828
}

src/jsMain/kotlin/io/github/oshai/kotlinlogging/KotlinLoggingConfiguration.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public actual object KotlinLoggingConfiguration {
1111
set(value) {
1212
appender = value
1313
}
14+
1415
@Deprecated("Use logLevel instead", ReplaceWith("logLevel"))
1516
public var LOG_LEVEL: Level
1617
get() = logLevel

src/jvmMain/kotlin/io/github/oshai/kotlinlogging/KotlinLoggingMDC.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import org.slf4j.MDC
1818
public inline fun <T> withLoggingContext(
1919
pair: Pair<String, String?>,
2020
restorePrevious: Boolean = true,
21-
body: () -> T
21+
body: () -> T,
2222
): T =
2323
if (pair.second == null) {
2424
body()
@@ -44,7 +44,7 @@ public inline fun <T> withLoggingContext(
4444
public inline fun <T> withLoggingContext(
4545
vararg pair: Pair<String, String?>,
4646
restorePrevious: Boolean = true,
47-
body: () -> T
47+
body: () -> T,
4848
): T {
4949
val pairForMDC = pair.filter { it.second != null }
5050
val cleanupCallbacks =
@@ -81,7 +81,7 @@ public inline fun <T> withLoggingContext(
8181
public inline fun <T> withLoggingContext(
8282
map: Map<String, String?>,
8383
restorePrevious: Boolean = true,
84-
body: () -> T
84+
body: () -> T,
8585
): T {
8686
val cleanupCallbacks =
8787
map.map {

src/jvmMain/kotlin/io/github/oshai/kotlinlogging/coroutines/KotlinLoggingAsyncMDC.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import kotlinx.coroutines.slf4j.*
2020
public suspend inline fun <T> withLoggingContextAsync(
2121
pair: Pair<String, String?>,
2222
restorePrevious: Boolean = true,
23-
crossinline body: suspend () -> T
23+
crossinline body: suspend () -> T,
2424
): T =
2525
withLoggingContext(pair, restorePrevious = restorePrevious) {
2626
withContext(MDCContext()) { body() }
@@ -37,7 +37,7 @@ public suspend inline fun <T> withLoggingContextAsync(
3737
public suspend inline fun <T> withLoggingContextAsync(
3838
vararg pair: Pair<String, String?>,
3939
restorePrevious: Boolean = true,
40-
crossinline body: suspend () -> T
40+
crossinline body: suspend () -> T,
4141
): T =
4242
withLoggingContext(*pair, restorePrevious = restorePrevious) {
4343
withContext(MDCContext()) { body() }
@@ -59,7 +59,7 @@ public suspend inline fun <T> withLoggingContextAsync(
5959
public suspend inline fun <T> withLoggingContextAsync(
6060
map: Map<String, String?>,
6161
restorePrevious: Boolean = true,
62-
crossinline body: suspend () -> T
62+
crossinline body: suspend () -> T,
6363
): T =
6464
withLoggingContext(map, restorePrevious = restorePrevious) {
6565
withContext(MDCContext()) { body() }

src/jvmMain/kotlin/io/github/oshai/kotlinlogging/jul/internal/JulLoggerWrapper.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal class JulLoggerWrapper(override val underlyingLogger: Logger) :
1616
override fun at(
1717
level: io.github.oshai.kotlinlogging.Level,
1818
marker: Marker?, // marker is not supported in JUL
19-
block: KLoggingEventBuilder.() -> Unit
19+
block: KLoggingEventBuilder.() -> Unit,
2020
) {
2121
if (isLoggingEnabledFor(level, null)) {
2222
KLoggingEventBuilder().apply(block).run {
@@ -27,7 +27,7 @@ internal class JulLoggerWrapper(override val underlyingLogger: Logger) :
2727

2828
override fun isLoggingEnabledFor(
2929
level: io.github.oshai.kotlinlogging.Level,
30-
marker: Marker?
30+
marker: Marker?,
3131
): Boolean {
3232
return underlyingLogger.isLoggable(level.toJULLevel())
3333
}

src/jvmTest/kotlin/io/github/oshai/kotlinlogging/AppenderWithWriter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ data class AppenderWithWriter(
2525
val pattern: String = "%-5p %c %marker - %m%n",
2626
val writer: StringWriter = StringWriter(),
2727
val appender: Appender =
28-
WriterAppender.createAppender(newPatternLayout(pattern), null, writer, "writer", false, true)
28+
WriterAppender.createAppender(newPatternLayout(pattern), null, writer, "writer", false, true),
2929
)

0 commit comments

Comments
 (0)