99 */
1010
1111#import < Cocoa/Cocoa.h>
12- #import < asl.h>
13-
1412
1513// Taken from /usr/include/AvailabilityMacros.h
1614#ifndef MAC_OS_X_VERSION_10_7
2826#ifndef MAC_OS_X_VERSION_10_11
2927# define MAC_OS_X_VERSION_10_11 101100
3028#endif
29+ #ifndef MAC_OS_X_VERSION_10_12
30+ # define MAC_OS_X_VERSION_10_12 101200
31+ #endif
3132
3233// Needed for pre-10.11 SDK
3334#ifndef NSAppKitVersionNumber10_10
3738# define NSAppKitVersionNumber10_10_Max 1349
3839#endif
3940
41+ #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
42+ // Deprecated constants in 10.12 SDK
43+ # define NSAlertStyleWarning NSWarningAlertStyle
44+ # define NSControlSizeRegular NSRegularControlSize
45+ # define NSEventModifierFlagCommand NSCommandKeyMask
46+ # define NSEventTypeLeftMouseUp NSLeftMouseUp
47+ # define NSEventTypeRightMouseDown NSRightMouseDown
48+ # define NSWindowStyleMaskClosable NSClosableWindowMask
49+ # define NSWindowStyleMaskFullScreen NSFullScreenWindowMask
50+ # define NSWindowStyleMaskMiniaturizable NSMiniaturizableWindowMask
51+ # define NSWindowStyleMaskResizable NSResizableWindowMask
52+ # define NSWindowStyleMaskTexturedBackground NSTexturedBackgroundWindowMask
53+ # define NSWindowStyleMaskTitled NSTitledWindowMask
54+ # define NSWindowStyleMaskUnifiedTitleAndToolbar NSUnifiedTitleAndToolbarWindowMask
55+ #endif
56+
57+ #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
58+ # import < asl.h>
59+ # define MM_USE_ASL
60+ #else
61+ # import < os/log.h>
62+ #endif
63+
4064
4165//
4266// This is the protocol MMBackend implements.
@@ -360,7 +384,10 @@ extern int ASLogLevel;
360384
361385void ASLInit ();
362386
363- #define ASLog (level, fmt, ...) \
387+ #if defined(MM_USE_ASL)
388+
389+ # define MM_ASL_LEVEL_DEFAULT ASL_LEVEL_NOTICE
390+ # define ASLog (level, fmt, ...) \
364391 if (level <= ASLogLevel) { \
365392 asl_log (NULL , NULL , level, " %s @%d : %s " , \
366393 __PRETTY_FUNCTION__, __LINE__, \
@@ -369,10 +396,30 @@ void ASLInit();
369396
370397// Note: These macros are used like ASLogErr(@"text num=%d", 42). Objective-C
371398// style specifiers (%@) are supported.
372- #define ASLogCrit (fmt, ...) ASLog(ASL_LEVEL_CRIT, fmt, ##__VA_ARGS__)
373- #define ASLogErr (fmt, ...) ASLog(ASL_LEVEL_ERR, fmt, ##__VA_ARGS__)
374- #define ASLogWarn (fmt, ...) ASLog(ASL_LEVEL_WARNING, fmt, ##__VA_ARGS__)
375- #define ASLogNotice (fmt, ...) ASLog(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
376- #define ASLogInfo (fmt, ...) ASLog(ASL_LEVEL_INFO, fmt, ##__VA_ARGS__)
377- #define ASLogDebug (fmt, ...) ASLog(ASL_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
378- #define ASLogTmp (fmt, ...) ASLog(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
399+ # define ASLogCrit (fmt, ...) ASLog(ASL_LEVEL_CRIT, fmt, ##__VA_ARGS__)
400+ # define ASLogErr (fmt, ...) ASLog(ASL_LEVEL_ERR, fmt, ##__VA_ARGS__)
401+ # define ASLogWarn (fmt, ...) ASLog(ASL_LEVEL_WARNING, fmt, ##__VA_ARGS__)
402+ # define ASLogNotice (fmt, ...) ASLog(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
403+ # define ASLogInfo (fmt, ...) ASLog(ASL_LEVEL_INFO, fmt, ##__VA_ARGS__)
404+ # define ASLogDebug (fmt, ...) ASLog(ASL_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
405+ # define ASLogTmp (fmt, ...) ASLog(ASL_LEVEL_NOTICE, fmt, ##__VA_ARGS__)
406+
407+ #else
408+
409+ # define MM_ASL_LEVEL_DEFAULT OS_LOG_TYPE_DEFAULT
410+ # define ASLog (level, fmt, ...) \
411+ if (level <= ASLogLevel) { \
412+ os_log_with_type (OS_LOG_DEFAULT, level, " %s @%d : %s " , \
413+ __PRETTY_FUNCTION__, __LINE__, \
414+ [[NSString stringWithFormat: fmt, ##__VA_ARGS__] UTF8String ]); \
415+ }
416+
417+ # define ASLogCrit (fmt, ...) ASLog(OS_LOG_TYPE_FAULT, fmt, ##__VA_ARGS__)
418+ # define ASLogErr (fmt, ...) ASLog(OS_LOG_TYPE_ERROR, fmt, ##__VA_ARGS__)
419+ # define ASLogWarn (fmt, ...) ASLog(OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__)
420+ # define ASLogNotice (fmt, ...) ASLog(OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__)
421+ # define ASLogInfo (fmt, ...) ASLog(OS_LOG_TYPE_INFO, fmt, ##__VA_ARGS__)
422+ # define ASLogDebug (fmt, ...) ASLog(OS_LOG_TYPE_DEBUG, fmt, ##__VA_ARGS__)
423+ # define ASLogTmp (fmt, ...) ASLog(OS_LOG_TYPE_DEFAULT, fmt, ##__VA_ARGS__)
424+
425+ #endif
0 commit comments