summaryrefslogtreecommitdiff
path: root/platform/darwin/src/MGLLoggingConfiguration_Private.h
diff options
context:
space:
mode:
authorFabian Guerra Soto <fabian.guerra@mapbox.com>2018-11-14 15:42:18 -0800
committerGitHub <noreply@github.com>2018-11-14 15:42:18 -0800
commitc8fbcfd322e1af4520f0bdc7e5945f6ffd3b4b73 (patch)
tree9158facaa7fc8b728a69f87f494a71fb659d9727 /platform/darwin/src/MGLLoggingConfiguration_Private.h
parent86677b97c6d5e7db75358e9f5745dab4cec5d0e4 (diff)
downloadqtlocation-mapboxgl-c8fbcfd322e1af4520f0bdc7e5945f6ffd3b4b73.tar.gz
[ios, macos] Logging. (#13235)
* [ios, macos] Update the logging subsystem to platform agnostic. * [ios, macos] Add coordinate to string function. * [ios, macos] Add BOOL to string function. * [ios, macos] Add tracing logs. * [ios, macos] Add tracing logs to generated style classes. * [ios, macos] Split logging categories accordingly to MGLLoggingLevel. * [ios, macos] Log network requests. * [ios, macos] Migrate NSAssert to MGLAssert. * [ios, macos] Include MGLLoggingConfiguration to filesource-files.txt. * [ios, macos] Fix logger string specifier for the line parameter. * [ios, macos] Add logs to shapes classes. * [ios, macos] Add logs to offline classes. * [ios, macos] Add logs to annotation classes. * [ios, macos] Add logs to foundation classes. * [ios, macos] Fix snapshotter size logging. * [macos] Add logs to map view. * [ios, macos] Fix string from boolean prefix, add custom function for NSCAssert. * Log size test * [ios, macos] Add logging conditional compilation flag. * [ios, macos] Rename function NSStringFromMGLTransition to MGLStringFromMGLTransition. * [ios, macos] Remove verbose logging for release builds. * [ios, macos] Rename NSStringFromCLLocationCoordinate2D to MGLStringFromCLLocationCoordinate2D. * [ios, macos] Clean unnecesary blank lines in MGLLight.mm set methods. * [ios, macos] Fix logging grammar, format, function names. * [ios, macos] Remove compilation flag, rename flags.
Diffstat (limited to 'platform/darwin/src/MGLLoggingConfiguration_Private.h')
-rw-r--r--platform/darwin/src/MGLLoggingConfiguration_Private.h42
1 files changed, 41 insertions, 1 deletions
diff --git a/platform/darwin/src/MGLLoggingConfiguration_Private.h b/platform/darwin/src/MGLLoggingConfiguration_Private.h
index ff7e85eed8..34e999ca72 100644
--- a/platform/darwin/src/MGLLoggingConfiguration_Private.h
+++ b/platform/darwin/src/MGLLoggingConfiguration_Private.h
@@ -1,9 +1,48 @@
#import "MGLLoggingConfiguration.h"
+NS_INLINE NSString *MGLStringFromBOOL(BOOL value) {
+ return value ? @"YES" : @"NO";
+}
+
+#ifdef MGL_LOGGING_DISABLED
+
+#define MGLLogInfo(...)
+#define MGLLogDebug(...)
+#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 MGLLogDebug(message, ...) MGLLogWithType(MGLLoggingLevelDebug, __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) \
@@ -17,3 +56,4 @@
- (void)logCallingFunction:(const char *)callingFunction functionLine:(NSUInteger)functionLine messageType:(MGLLoggingLevel)type format:(id)messageFormat, ...;
@end
+#endif