diff options
author | Ryan Wilson <wilsonryan@google.com> | 2017-09-15 19:59:56 -0400 |
---|---|---|
committer | Paul Beusterien <paulbeusterien@google.com> | 2017-09-15 16:59:56 -0700 |
commit | b79950072d349d2b3665b05c71cf5cb9953ef6ed (patch) | |
tree | 9c9bcb25da3f6f6f7c6c4ea96b732c6f190b0d14 /Firebase/Core/FIRLogger.m | |
parent | c6bde890ce2b352f86aa699b28f829d4cd85424c (diff) |
Remove duplicate logging issue. (#279)
Some combinations of iOS version, simulator/device, and Xcode version
result in duplicate logs. This should remove duplicate logs while
ensuring that all Firebase related logs are still shown.
Diffstat (limited to 'Firebase/Core/FIRLogger.m')
-rw-r--r-- | Firebase/Core/FIRLogger.m | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/Firebase/Core/FIRLogger.m b/Firebase/Core/FIRLogger.m index 6f2caef..1140beb 100644 --- a/Firebase/Core/FIRLogger.m +++ b/Firebase/Core/FIRLogger.m @@ -77,8 +77,22 @@ static NSRegularExpression *sMessageCodeRegex; void FIRLoggerInitializeASL() { dispatch_once(&sFIRLoggerOnceToken, ^{ + NSInteger majorOSVersion = [[FIRAppEnvironmentUtil systemVersion] integerValue]; + uint32_t aslOptions = ASL_OPT_STDERR; +#if TARGET_OS_SIMULATOR + // The iOS 11 simulator doesn't need the ASL_OPT_STDERR flag. + if (majorOSVersion >= 11) { + aslOptions = 0; + } +#else + // Devices running iOS 10 or higher don't need the ASL_OPT_STDERR flag. + if (majorOSVersion >= 10) { + aslOptions = 0; + } +#endif // TARGET_OS_SIMULATOR + // Initialize the ASL client handle. - sFIRLoggerClient = asl_open(NULL, kFIRLoggerASLClientFacilityName, ASL_OPT_STDERR); + sFIRLoggerClient = asl_open(NULL, kFIRLoggerASLClientFacilityName, aslOptions); // Set the filter used by system/device log. Initialize in default mode. asl_set_filter(sFIRLoggerClient, ASL_FILTER_MASK_UPTO(ASL_LEVEL_NOTICE)); @@ -104,11 +118,15 @@ void FIRLoggerInitializeASL() { sFIRLoggerDebugMode = NO; } - // Need to call asl_add_output_file so that the logs can appear in Xcode's console view. Set - // the ASL filter mask for this output file up to debug level so that all messages are - // viewable in the console. - asl_add_output_file(sFIRLoggerClient, STDERR_FILENO, kFIRLoggerCustomASLMessageFormat, - ASL_TIME_FMT_LCL, ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG), ASL_ENCODE_SAFE); +#if TARGET_OS_SIMULATOR + // Need to call asl_add_output_file so that the logs can appear in Xcode's console view when + // running iOS 7. Set the ASL filter mask for this output file up to debug level so that all + // messages are viewable in the console. + if (majorOSVersion == 7) { + asl_add_output_file(sFIRLoggerClient, STDERR_FILENO, kFIRLoggerCustomASLMessageFormat, + ASL_TIME_FMT_LCL, ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG), ASL_ENCODE_SAFE); + } +#endif // TARGET_OS_SIMULATOR sFIRClientQueue = dispatch_queue_create("FIRLoggingClientQueue", DISPATCH_QUEUE_SERIAL); dispatch_set_target_queue(sFIRClientQueue, |