Files
MapLibreParticleLab/platform/darwin/src/MGLLoggingConfiguration_Private.h
m-stephen 2e5897c0f4 [ios, macos]MGLLoggingConfiguration can filter logs from core (#15120)
* [ios, macos] update proj config

* [ios, macos] implement the logging logic

* [ios, macos] update comments

* [ios, macos] update mac os config

* [ios, macos] re-generate sdk files

* [ios, macos] re-generate sdk files json

* [ios, macos]re-generate json files

* [ios, macos] re-generate ios json files

* [ios] change conditions to bit mask

* [ios, macos]send messages to platform

* [ios, macos] add changelogs

* [ios, macos] revert `logging_nslog`

* [ios, macos] add event name and code into log msg

* [ios, macos] update changlog

* [ios, macos] fix a nit

* [ios, macos]Fix nits.
2019-07-25 15:39:01 +08:00

68 lines
2.3 KiB
Objective-C

#import "MGLLoggingConfiguration.h"
NS_INLINE NSString *MGLStringFromBOOL(BOOL value) {
return value ? @"YES" : @"NO";
}
#if TARGET_OS_OSX
NS_INLINE NSString *MGLStringFromNSEdgeInsets(NSEdgeInsets insets) {
return [NSString stringWithFormat:@"{ top: %f, left: %f, bottom: %f, right: %f", insets.top, insets.left, insets.bottom, insets.right];
}
#endif
#ifdef MGL_LOGGING_DISABLED
#define MGLLogInfo(...)
#define MGLLogDebug(...)
#define MGLLogWarning(...)
#define MGLLogError(...)
#define MGLLogFault(...)
#else
#if MGL_LOGGING_ENABLE_DEBUG
#define MGLLogDebug(message, ...) MGLLogWithType(MGLLoggingLevelDebug, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__)
#else
#define MGLLogDebug(...)
#endif
#define MGLLogInfo(message, ...) MGLLogWithType(MGLLoggingLevelInfo, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__)
#define MGLLogWarning(message, ...) MGLLogWithType(MGLLoggingLevelWarning, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__)
#define MGLLogError(message, ...) MGLLogWithType(MGLLoggingLevelError, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__)
#define MGLLogFault(message, ...) MGLLogWithType(MGLLoggingLevelFault, __PRETTY_FUNCTION__, __LINE__, message, ##__VA_ARGS__)
#endif
#define MGLAssert(expression, message, ...) \
__extension__({ \
if (__builtin_expect(!(expression), 0)) { \
MGLLogFault(message, ##__VA_ARGS__); \
} \
NSAssert(expression, message, ##__VA_ARGS__); \
})
#define MGLCAssert(expression, message, ...) \
__extension__({ \
if (__builtin_expect(!(expression), 0)) { \
MGLLogFault(message, ##__VA_ARGS__); \
} \
NSCAssert(expression, message, ##__VA_ARGS__); \
})
#ifndef MGL_LOGGING_DISABLED
#define MGLLogWithType(type, function, line, message, ...) \
{ \
if ([MGLLoggingConfiguration sharedConfiguration].loggingLevel != MGLLoggingLevelNone && type <= [MGLLoggingConfiguration sharedConfiguration].loggingLevel) \
{ \
[[MGLLoggingConfiguration sharedConfiguration] logCallingFunction:function functionLine:line messageType:type format:(message), ##__VA_ARGS__]; \
} \
}
@interface MGLLoggingConfiguration (Private)
- (void)logCallingFunction:(const char *)callingFunction functionLine:(NSUInteger)functionLine messageType:(MGLLoggingLevel)type format:(id)messageFormat, ...;
@end
#endif