Skip to content

Remove duplicate logging issue. #279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions Firebase/Core/FIRLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,22 @@

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));
Expand All @@ -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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test on majorOSVersion 8,9,10 simulators, since this block would have been executed for them before?

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,
Expand Down