diff options
author | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-11-01 14:34:57 -0700 |
---|---|---|
committer | Fabian Guerra <fabian.guerra@mapbox.com> | 2018-11-13 15:56:40 -0800 |
commit | 7f35b5dd1721ab645891834c6910d3e3281bdfb3 (patch) | |
tree | 946c923a00e2606641ed3b08da6c07d9783b3fda | |
parent | d27ec49fb1f2369c463615aeb1191f7c7ef6e97e (diff) | |
download | qtlocation-mapboxgl-7f35b5dd1721ab645891834c6910d3e3281bdfb3.tar.gz |
[ios, macos] Split logging categories accordingly to MGLLoggingLevel.
-rw-r--r-- | platform/darwin/src/MGLLoggingConfiguration.m | 51 |
1 files changed, 48 insertions, 3 deletions
diff --git a/platform/darwin/src/MGLLoggingConfiguration.m b/platform/darwin/src/MGLLoggingConfiguration.m index da4155b758..21b8618f7b 100644 --- a/platform/darwin/src/MGLLoggingConfiguration.m +++ b/platform/darwin/src/MGLLoggingConfiguration.m @@ -42,21 +42,66 @@ if (@available(iOS 10.0, macOS 10.12.0, *)) { static dispatch_once_t once; - static os_log_t mapbox_log; + static os_log_t info_log; + static os_log_t debug_log; + static os_log_t error_log; + static os_log_t fault_log; static os_log_type_t log_types[] = { OS_LOG_TYPE_DEFAULT, OS_LOG_TYPE_INFO, OS_LOG_TYPE_DEBUG, OS_LOG_TYPE_ERROR, OS_LOG_TYPE_FAULT }; dispatch_once(&once, ^ { - mapbox_log = os_log_create("com.mapbox.maps", "SDK"); + info_log = os_log_create("com.mapbox.maps", "INFO"); + debug_log = os_log_create("com.mapbox.maps", "DEBUG"); + error_log = os_log_create("com.mapbox.maps", "ERROR"); + fault_log = os_log_create("com.mapbox.maps", "FAULT"); }); + + os_log_t mapbox_log; + switch (level) { + case MGLLoggingLevelInfo: + mapbox_log = info_log; + break; + case MGLLoggingLevelDebug: + mapbox_log = debug_log; + break; + case MGLLoggingLevelError: + mapbox_log = error_log; + break; + case MGLLoggingLevelFault: + mapbox_log = fault_log; + break; + case MGLLoggingLevelNone: + default: + break; + } + NSUInteger logTypesCount = sizeof(log_types) / sizeof(os_log_type_t); NSAssert(level <= logTypesCount, @"There is an attempt to log a non suported logging level."); os_log_type_t logType = log_types[level]; os_log_with_type(mapbox_log, logType, "%@ - %d: %@", fileName, line, message); } else { - NSLog(@"[SDK] %@ - %lu: %@", fileName, line, message); + NSString *category; + switch (level) { + case MGLLoggingLevelInfo: + category = @"INFO"; + break; + case MGLLoggingLevelDebug: + category = @"DEBUG"; + break; + case MGLLoggingLevelError: + category = @"ERROR"; + break; + case MGLLoggingLevelFault: + category = @"FAULT"; + break; + case MGLLoggingLevelNone: + default: + break; + } + + NSLog(@"[%@] %@ - %lu: %@", category, fileName, line, message); } }; |