tunnelkit/Sources/TunnelKitWireGuardCore/Internal/Logger.swift

38 lines
856 B
Swift
Raw Normal View History

import SwiftyBeaver
private let log = SwiftyBeaver.self
extension OSLogType {
var sbLevel: SwiftyBeaver.Level {
switch self {
case .debug:
return .debug
2023-04-20 19:52:45 +00:00
case .info:
return .info
2023-04-20 19:52:45 +00:00
case .error, .fault:
return .error
default:
return .info
}
}
}
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation
import os.log
public func wg_log(_ type: OSLogType, staticMessage msg: StaticString) {
os_log(msg, log: OSLog.default, type: type)
log.custom(level: type.sbLevel, message: msg, context: nil)
}
public func wg_log(_ type: OSLogType, message msg: String) {
os_log("%{public}s", log: OSLog.default, type: type, msg)
log.custom(level: type.sbLevel, message: msg, context: nil)
}