-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes needed for compiler plugin (#474)
* Changes needed for compiler plugin * Hide the public API * Hide also toStringSafe() and castToThrowable() extension functions --------- Co-authored-by: Neeme Praks <neeme.praks@eesti.ee>
- Loading branch information
1 parent
e14380d
commit 2b2dbc7
Showing
3 changed files
with
113 additions
and
3 deletions.
There are no files selected for viewing
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
109 changes: 109 additions & 0 deletions
109
src/commonMain/kotlin/io/github/oshai/kotlinlogging/internal/KLoggerHiddenExtensions.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,109 @@ | ||
package io.github.oshai.kotlinlogging.internal | ||
|
||
import io.github.oshai.kotlinlogging.KLogger | ||
import io.github.oshai.kotlinlogging.KLoggingEventBuilder | ||
|
||
@Deprecated( | ||
message = "This is an internal API and should not be used by user code", | ||
level = DeprecationLevel.HIDDEN, | ||
) | ||
@Suppress("kotlin:S1133") | ||
public fun (() -> Any?).hiddenToStringSafe(): String = toStringSafe() | ||
|
||
@Deprecated( | ||
message = "This is an internal API and should not be used by user code", | ||
level = DeprecationLevel.HIDDEN, | ||
) | ||
@Suppress("kotlin:S1133") | ||
public fun Any?.hiddenCastToThrowable(): Throwable? { | ||
return if (this is Throwable) { | ||
this | ||
} else { | ||
null | ||
} | ||
} | ||
|
||
@Deprecated( | ||
message = "This is an internal API and should not be used by user code", | ||
level = DeprecationLevel.HIDDEN, | ||
) | ||
@Suppress("kotlin:S1133") | ||
public fun KLoggingEventBuilder.hiddenInternalCompilerData( | ||
compilerData: KLoggingEventBuilder.InternalCompilerData | ||
) { | ||
internalCompilerData = compilerData | ||
} | ||
|
||
@Deprecated( | ||
message = "This is an internal API and should not be used by user code", | ||
level = DeprecationLevel.HIDDEN, | ||
) | ||
@Suppress("kotlin:S1133") | ||
public fun KLogger.entryWithCompilerData( | ||
compilerData: KLoggingEventBuilder.InternalCompilerData? = null, | ||
vararg arguments: Any?, | ||
): Unit = atTrace { | ||
message = "entry(${arguments.joinToString()})" | ||
internalCompilerData = compilerData | ||
} | ||
|
||
@Deprecated( | ||
message = "This is an internal API and should not be used by user code", | ||
level = DeprecationLevel.HIDDEN, | ||
) | ||
@Suppress("kotlin:S1133") | ||
public fun KLogger.exitWithCompilerData( | ||
compilerData: KLoggingEventBuilder.InternalCompilerData? = null | ||
): Unit = atTrace { | ||
message = "exit" | ||
internalCompilerData = compilerData | ||
} | ||
|
||
@Deprecated( | ||
message = "This is an internal API and should not be used by user code", | ||
level = DeprecationLevel.HIDDEN, | ||
) | ||
@Suppress("kotlin:S1133") | ||
public fun <T> KLogger.exitWithCompilerData( | ||
compilerData: KLoggingEventBuilder.InternalCompilerData? = null, | ||
result: T, | ||
): T where T : Any? { | ||
atTrace { | ||
message = "exit($result)" | ||
internalCompilerData = compilerData | ||
} | ||
return result | ||
} | ||
|
||
@Deprecated( | ||
message = "This is an internal API and should not be used by user code", | ||
level = DeprecationLevel.HIDDEN, | ||
) | ||
@Suppress("kotlin:S1133") | ||
public fun <T> KLogger.throwingWithCompilerData( | ||
compilerData: KLoggingEventBuilder.InternalCompilerData? = null, | ||
throwable: T, | ||
): T where T : Throwable { | ||
atError { | ||
cause = throwable | ||
message = "throwing($throwable)" | ||
internalCompilerData = compilerData | ||
} | ||
return throwable | ||
} | ||
|
||
@Deprecated( | ||
message = "This is an internal API and should not be used by user code", | ||
level = DeprecationLevel.HIDDEN, | ||
) | ||
@Suppress("kotlin:S1133") | ||
public fun <T> KLogger.catchingWithCompilerData( | ||
compilerData: KLoggingEventBuilder.InternalCompilerData? = null, | ||
throwable: T, | ||
) where T : Throwable { | ||
atError { | ||
cause = throwable | ||
message = "catching($throwable)" | ||
internalCompilerData = compilerData | ||
} | ||
} |
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