mirror of https://github.com/mpv-player/mpv
mac/log: properly guard logger usage behind platform version check
This commit is contained in:
parent
1acb49f9c6
commit
b390ade709
|
@ -20,7 +20,12 @@ import os
|
|||
|
||||
class LogHelper {
|
||||
var log: OpaquePointer?
|
||||
let logger = Logger(subsystem: "io.mpv", category: "mpv")
|
||||
#if HAVE_MACOS_11_FEATURES
|
||||
@available(macOS 11.0, *)
|
||||
var logger: Logger? {
|
||||
return Logger(subsystem: "io.mpv", category: "mpv")
|
||||
}
|
||||
#endif
|
||||
|
||||
let loggerMapping: [Int: OSLogType] = [
|
||||
MSGL_V: .debug,
|
||||
|
@ -51,7 +56,11 @@ class LogHelper {
|
|||
|
||||
func send(message: String, type: Int) {
|
||||
guard let log = log else {
|
||||
logger.log(level: loggerMapping[type] ?? .default, "\(message, privacy: .public)")
|
||||
#if HAVE_MACOS_11_FEATURES
|
||||
if #available(macOS 11.0, *) {
|
||||
logger?.log(level: loggerMapping[type] ?? .default, "\(message, privacy: .public)")
|
||||
}
|
||||
#endif
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue