Skip to content

Commit

Permalink
Log marker and stacktrace on Darwin (#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 authored Jan 15, 2024
1 parent c08fdf2 commit d13df90
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,23 @@ 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 d13df90

Please sign in to comment.