50
50
# include <mach-o/loader.h>
51
51
// The os_log unified logging APIs were introduced in macOS 10.12, iOS 10.0,
52
52
// tvOS 10.0, and watchOS 3.0;
53
- # if defined(TARGET_OS_IPHONE ) && TARGET_IOS_IPHONE
53
+ # if defined(TARGET_OS_IPHONE ) && TARGET_OS_IPHONE
54
54
# define HAS_APPLE_SYSTEM_LOG 1
55
55
# elif defined(TARGET_OS_OSX ) && TARGET_OS_OSX
56
56
# if defined(MAC_OS_X_VERSION_10_12 ) && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_12
@@ -94,7 +94,7 @@ static PyStatus init_sys_streams(PyThreadState *tstate);
94
94
#ifdef __ANDROID__
95
95
static PyStatus init_android_streams (PyThreadState * tstate );
96
96
#endif
97
- #if defined(__APPLE__ )
97
+ #if defined(__APPLE__ ) && HAS_APPLE_SYSTEM_LOG
98
98
static PyStatus init_apple_streams (PyThreadState * tstate );
99
99
#endif
100
100
static void wait_for_thread_shutdown (PyThreadState * tstate );
@@ -1279,7 +1279,7 @@ init_interp_main(PyThreadState *tstate)
1279
1279
return status ;
1280
1280
}
1281
1281
#endif
1282
- #if defined(__APPLE__ )
1282
+ #if defined(__APPLE__ ) && HAS_APPLE_SYSTEM_LOG
1283
1283
if (config -> use_system_logger ) {
1284
1284
status = init_apple_streams (tstate );
1285
1285
if (_PyStatus_EXCEPTION (status )) {
@@ -2963,7 +2963,7 @@ init_android_streams(PyThreadState *tstate)
2963
2963
2964
2964
#endif // __ANDROID__
2965
2965
2966
- #if defined(__APPLE__ )
2966
+ #if defined(__APPLE__ ) && HAS_APPLE_SYSTEM_LOG
2967
2967
2968
2968
static PyObject *
2969
2969
apple_log_write_impl (PyObject * self , PyObject * args )
@@ -2974,14 +2974,9 @@ apple_log_write_impl(PyObject *self, PyObject *args)
2974
2974
return NULL ;
2975
2975
}
2976
2976
2977
- // Call the underlying Apple logging API. The os_log unified logging APIs
2978
- // were introduced in macOS 10.12, iOS 10.0, tvOS 10.0, and watchOS 3.0;
2979
- // this call is a no-op on older versions.
2980
- #if HAS_APPLE_SYSTEM_LOG
2981
2977
// Pass the user-provided text through explicit %s formatting
2982
2978
// to avoid % literals being interpreted as a formatting directive.
2983
2979
os_log_with_type (OS_LOG_DEFAULT , logtype , "%s" , text );
2984
- #endif
2985
2980
Py_RETURN_NONE ;
2986
2981
}
2987
2982
@@ -3016,7 +3011,6 @@ init_apple_streams(PyThreadState *tstate)
3016
3011
if (result == NULL ) {
3017
3012
goto error ;
3018
3013
}
3019
-
3020
3014
goto done ;
3021
3015
3022
3016
error :
@@ -3030,7 +3024,7 @@ init_apple_streams(PyThreadState *tstate)
3030
3024
return status ;
3031
3025
}
3032
3026
3033
- #endif // __APPLE__
3027
+ #endif // __APPLE__ && HAS_APPLE_SYSTEM_LOG
3034
3028
3035
3029
3036
3030
static void
0 commit comments