TraceLog/sample-kmp/src/commonMain/kotlin/Main.kt

28 lines
727 B
Kotlin

import dev.msfjarvis.tracelog.runtime.annotations.DebugLog
fun main() {
debuggableFunction("First parameter")
try {
throwingFunction()
} catch (_: Exception) {}
LogPrinter.printLogs()
}
/** Custom implementation of a logger function for use by the compiler plugin. */
@Suppress("Unused") // Used by the generated bytecode
fun recordMessage(message: Any?) {
LogPrinter.submitLog(message.toString())
}
/** An example of an annotated method which will be transformed by the compiler plugin. */
@DebugLog
@Suppress("UNUSED_PARAMETER")
fun debuggableFunction(p0: String, p1: String = "Bar"): String {
return "Debugging is cool!"
}
@DebugLog
fun throwingFunction() {
throw Exception("This code is throwing!")
}