|
| 1 | +package io.github.oshai.kotlinlogging.internal |
| 2 | + |
| 3 | +import io.github.oshai.kotlinlogging.KLogger |
| 4 | +import io.github.oshai.kotlinlogging.KLoggingEventBuilder |
| 5 | + |
| 6 | +@Deprecated( |
| 7 | + message = "This is an internal API and should not be used by user code", |
| 8 | + level = DeprecationLevel.HIDDEN, |
| 9 | +) |
| 10 | +@Suppress("kotlin:S1133") |
| 11 | +public fun (() -> Any?).hiddenToStringSafe(): String = toStringSafe() |
| 12 | + |
| 13 | +@Deprecated( |
| 14 | + message = "This is an internal API and should not be used by user code", |
| 15 | + level = DeprecationLevel.HIDDEN, |
| 16 | +) |
| 17 | +@Suppress("kotlin:S1133") |
| 18 | +public fun Any?.hiddenCastToThrowable(): Throwable? { |
| 19 | + return if (this is Throwable) { |
| 20 | + this |
| 21 | + } else { |
| 22 | + null |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +@Deprecated( |
| 27 | + message = "This is an internal API and should not be used by user code", |
| 28 | + level = DeprecationLevel.HIDDEN, |
| 29 | +) |
| 30 | +@Suppress("kotlin:S1133") |
| 31 | +public fun KLoggingEventBuilder.hiddenInternalCompilerData( |
| 32 | + compilerData: KLoggingEventBuilder.InternalCompilerData |
| 33 | +) { |
| 34 | + internalCompilerData = compilerData |
| 35 | +} |
| 36 | + |
| 37 | +@Deprecated( |
| 38 | + message = "This is an internal API and should not be used by user code", |
| 39 | + level = DeprecationLevel.HIDDEN, |
| 40 | +) |
| 41 | +@Suppress("kotlin:S1133") |
| 42 | +public fun KLogger.entryWithCompilerData( |
| 43 | + compilerData: KLoggingEventBuilder.InternalCompilerData? = null, |
| 44 | + vararg arguments: Any?, |
| 45 | +): Unit = atTrace { |
| 46 | + message = "entry(${arguments.joinToString()})" |
| 47 | + internalCompilerData = compilerData |
| 48 | +} |
| 49 | + |
| 50 | +@Deprecated( |
| 51 | + message = "This is an internal API and should not be used by user code", |
| 52 | + level = DeprecationLevel.HIDDEN, |
| 53 | +) |
| 54 | +@Suppress("kotlin:S1133") |
| 55 | +public fun KLogger.exitWithCompilerData( |
| 56 | + compilerData: KLoggingEventBuilder.InternalCompilerData? = null |
| 57 | +): Unit = atTrace { |
| 58 | + message = "exit" |
| 59 | + internalCompilerData = compilerData |
| 60 | +} |
| 61 | + |
| 62 | +@Deprecated( |
| 63 | + message = "This is an internal API and should not be used by user code", |
| 64 | + level = DeprecationLevel.HIDDEN, |
| 65 | +) |
| 66 | +@Suppress("kotlin:S1133") |
| 67 | +public fun <T> KLogger.exitWithCompilerData( |
| 68 | + compilerData: KLoggingEventBuilder.InternalCompilerData? = null, |
| 69 | + result: T, |
| 70 | +): T where T : Any? { |
| 71 | + atTrace { |
| 72 | + message = "exit($result)" |
| 73 | + internalCompilerData = compilerData |
| 74 | + } |
| 75 | + return result |
| 76 | +} |
| 77 | + |
| 78 | +@Deprecated( |
| 79 | + message = "This is an internal API and should not be used by user code", |
| 80 | + level = DeprecationLevel.HIDDEN, |
| 81 | +) |
| 82 | +@Suppress("kotlin:S1133") |
| 83 | +public fun <T> KLogger.throwingWithCompilerData( |
| 84 | + compilerData: KLoggingEventBuilder.InternalCompilerData? = null, |
| 85 | + throwable: T, |
| 86 | +): T where T : Throwable { |
| 87 | + atError { |
| 88 | + cause = throwable |
| 89 | + message = "throwing($throwable)" |
| 90 | + internalCompilerData = compilerData |
| 91 | + } |
| 92 | + return throwable |
| 93 | +} |
| 94 | + |
| 95 | +@Deprecated( |
| 96 | + message = "This is an internal API and should not be used by user code", |
| 97 | + level = DeprecationLevel.HIDDEN, |
| 98 | +) |
| 99 | +@Suppress("kotlin:S1133") |
| 100 | +public fun <T> KLogger.catchingWithCompilerData( |
| 101 | + compilerData: KLoggingEventBuilder.InternalCompilerData? = null, |
| 102 | + throwable: T, |
| 103 | +) where T : Throwable { |
| 104 | + atError { |
| 105 | + cause = throwable |
| 106 | + message = "catching($throwable)" |
| 107 | + internalCompilerData = compilerData |
| 108 | + } |
| 109 | +} |
0 commit comments