Skip to content

Commit

Permalink
Log marker and stacktrace on Darwin
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Dec 5, 2023
1 parent 433d4c3 commit f5e13da
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@ public class DarwinKLogger(override val name: String, override val underlyingLog
override fun at(level: Level, marker: Marker?, block: KLoggingEventBuilder.() -> Unit) {
if (isLoggingEnabledFor(level, marker)) {
KLoggingEventBuilder().apply(block).run {
_os_log_internal(__dso_handle.ptr, underlyingLogger, level.toDarwinLevel(), message)
val formattedMessage = buildString {
marker?.getName()?.let {
append(it)
append(" ")
}
append(message)
cause?.stackTraceToString()?.let {
append('\n')
append(it)
}
}
_os_log_internal(__dso_handle.ptr, underlyingLogger, level.toDarwinLevel(), formattedMessage)
}
}
}
Expand Down

0 comments on commit f5e13da

Please sign in to comment.