Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OSLogWriter structured logging takes optional subsystem and category #409

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ import kotlin.experimental.ExperimentalNativeApi
*/
open class OSLogWriter internal constructor(
private val messageStringFormatter: MessageStringFormatter,
private val darwinLogger: DarwinLogger
private val darwinLogger: DarwinLogger,
) : LogWriter() {

constructor(messageStringFormatter: MessageStringFormatter = DefaultFormatter) : this(
constructor(messageStringFormatter: MessageStringFormatter = DefaultFormatter, subsystem: String = "", category: String = "") : this(
messageStringFormatter,
DarwinLoggerActual
DarwinLoggerActual(subsystem, category),
)

override fun log(severity: Severity, message: String, tag: String, throwable: Throwable?) {
Expand Down Expand Up @@ -77,9 +77,9 @@ internal interface DarwinLogger {
}

@OptIn(ExperimentalForeignApi::class)
private object DarwinLoggerActual : DarwinLogger {
private val logger = darwin_log_create("", "")!!
private class DarwinLoggerActual(subsystem: String, category: String) : DarwinLogger {
private val logger = darwin_log_create(subsystem, category)!!
override fun log(osLogSeverity: os_log_type_t, message: String) {
darwin_log_with_type(logger, osLogSeverity, message)
}
}
}
Loading