Print debugging statement: Difference between revisions
Content deleted Content added
Line 252:
└ @ Main /usr/programming/test2.jl:13
</pre>
=={{header|Kotlin}}==
<lang scala>fun printDebug(message: String) {
val exception = RuntimeException()
val stackTrace = exception.stackTrace
val stackTraceElement = stackTrace[1]
val fileName = stackTraceElement.fileName
val className = stackTraceElement.className
val methodName = stackTraceElement.methodName
val lineNumber = stackTraceElement.lineNumber
println("[DEBUG][$fileName $className.$methodName#$lineNumber] $message")
}
fun blah() {
printDebug("Made It!")
}
fun main() {
printDebug("Hello world.")
blah()
val oops = { printDebug("oops") }
oops.invoke()
fun nested() {
printDebug("nested")
}
nested()
}</lang>
{{out}}
<pre>[DEBUG][PrintDebuggingStatement.kt PrintDebuggingStatementKt.main#18] Hello world.
[DEBUG][PrintDebuggingStatement.kt PrintDebuggingStatementKt.blah#14] Made It!
[DEBUG][PrintDebuggingStatement.kt PrintDebuggingStatementKt$main$oops$1.invoke#21] oops
[DEBUG][PrintDebuggingStatement.kt PrintDebuggingStatementKt$main$1.invoke#25] nested</pre>
=={{header|Mercury}}==
|