From b390ade7091b2d628fd5ef0feba241b4231b6c2b Mon Sep 17 00:00:00 2001 From: der richter Date: Sun, 9 Jun 2024 14:41:10 +0200 Subject: [PATCH] mac/log: properly guard logger usage behind platform version check --- osdep/mac/log_helper.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/osdep/mac/log_helper.swift b/osdep/mac/log_helper.swift index 690d7bcbc1..b3464fd1bd 100644 --- a/osdep/mac/log_helper.swift +++ b/osdep/mac/log_helper.swift @@ -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 }