     withUnsafeMutableBytes(of: &buffer) {
         guard let buffer = $0.baseAddress else { return }
         let msg = buffer.assumingMemoryBound(to: CChar.self)
-        g_logv(nil, level, msg, CVaListPointer(_fromUnsafeMutablePointer: buffer))
+        g_logv(nil, level.value, msg, CVaListPointer(_fromUnsafeMutablePointer: buffer))
     }
 }
 

///   - domain: the domain this logging occurs in (defaults to `nil`)
public func g_warning(_ message: String, domain: String? = nil) {
    if let d = domain {
        g_log(domain: d, message, level: .level_warning)
    } else {
        g_log(message, level: .level_warning)
    }
}

/// Opaque type. See RecMutexLocker for details.
public struct GRecMutexLocker {}

public extension LogLevelFlags {
    /// log level for debug messages, see `g_debug()`
    static let debug = LogLevelFlags.levelDebug
    /// log level for informational messages, see `g_info()`
    static let info = LogLevelFlags.levelInfo
    /// log level for warnings, see `g_warning()`
    static let warning = LogLevelFlags.levelWarning
    /// log level for critical warning messages, see
    ///     `g_critical()`.
    ///     This level is also used for messages produced by `g_return_if_fail()`
    ///     and `g_return_val_if_fail()`.
    static let critical = LogLevelFlags.levelCritical
    /// log level for errors, see `g_error()`.
    ///     This level is also used for messages produced by `g_assert()`.
    static let error = LogLevelFlags.levelError
}

#if !os(Linux)
/// Logging function
///
/// - Parameters:
///   - message: log message
///   - level: log level (defaults to `.debug`)
public func g_log(_ message: String, level: LogLevelFlags = .debug) {
    message.utf8CString.withUnsafeBufferPointer {
        guard let base = $0.baseAddress else { return }
        let varargs = [OpaquePointer(base)]
        withVaList(varargs) {
            g_logv(nil, level.value, "%s", $0)
        }
    }
}
