|
46 | 46 |
|
47 | 47 | #if defined(__APPLE__) |
48 | 48 | # include <AvailabilityMacros.h> |
| 49 | +# include <TargetConditionals.h> |
49 | 50 | # include <mach-o/loader.h> |
50 | 51 | // The os_log unified logging APIs were introduced in macOS 10.12, iOS 10.0, |
51 | 52 | // tvOS 10.0, and watchOS 3.0; |
52 | | -# if TARGET_OS_IPHONE || (TARGET_OS_OSX && defined(MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12) |
| 53 | +# if defined(TARGET_OS_IPHONE) && TARGET_IOS_IPHONE |
| 54 | +# define HAS_APPLE_SYSTEM_LOG 1 |
| 55 | +# elif defined(TARGET_OS_OSX) && TARGET_OS_OSX |
| 56 | +# if defined(MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12 |
| 57 | +# define HAS_APPLE_SYSTEM_LOG 1 |
| 58 | +# else |
| 59 | +# define HAS_APPLE_SYSTEM_LOG 0 |
| 60 | +# endif |
| 61 | +# else |
| 62 | +# define HAS_APPLE_SYSTEM_LOG 0 |
| 63 | +# endif |
| 64 | + |
| 65 | +# if HAS_APPLE_SYSTEM_LOG |
53 | 66 | # include <os/log.h> |
54 | 67 | # endif |
55 | 68 | #endif |
@@ -2964,7 +2977,7 @@ apple_log_write_impl(PyObject *self, PyObject *args) |
2964 | 2977 | // Call the underlying Apple logging API. The os_log unified logging APIs |
2965 | 2978 | // were introduced in macOS 10.12, iOS 10.0, tvOS 10.0, and watchOS 3.0; |
2966 | 2979 | // this call is a no-op on older versions. |
2967 | | - #if TARGET_OS_IPHONE || (TARGET_OS_OSX && defined(MAC_OS_X_VERSION_10_12) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12) |
| 2980 | + #if HAS_APPLE_SYSTEM_LOG |
2968 | 2981 | // Pass the user-provided text through explicit %s formatting |
2969 | 2982 | // to avoid % literals being interpreted as a formatting directive. |
2970 | 2983 | os_log_with_type(OS_LOG_DEFAULT, logtype, "%s", text); |
|
0 commit comments