Skip to content

Commit

Permalink
Added back the feature flag after discussion
Browse files Browse the repository at this point in the history
  • Loading branch information
mbruin-NR committed Nov 15, 2024
1 parent da9a987 commit 3b456c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Agent/FeatureFlags/NRMAFlags.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ + (NRMAFeatureFlags) featureFlags
NRFeatureFlag_NetworkRequestEvents |
NRFeatureFlag_RequestErrorEvents |
NRFeatureFlag_DistributedTracing |
NRFeatureFlag_AppStartMetrics;
NRFeatureFlag_AppStartMetrics |
NRFeatureFlag_AutoCollectLogs;
});
return __flags;
}
Expand Down Expand Up @@ -177,6 +178,10 @@ + (BOOL) shouldEnableBackgroundReporting {
return ([NRMAFlags featureFlags] & NRFeatureFlag_BackgroundReporting) != 0;
}

+ (BOOL) shouldEnableAutoCollectLogs {
return ([NRMAFlags featureFlags] & NRFeatureFlag_AutoCollectLogs) != 0;
}

+ (NSArray<NSString*>*) namesForFlags:(NRMAFeatureFlags)flags {
NSMutableArray *retArray = [NSMutableArray array];
if ((flags & NRFeatureFlag_InteractionTracing) == NRFeatureFlag_InteractionTracing) {
Expand Down Expand Up @@ -239,6 +244,9 @@ + (BOOL) shouldEnableBackgroundReporting {
if ((flags & NRFeatureFlag_BackgroundReporting) == NRFeatureFlag_BackgroundReporting) {
[retArray addObject:@"BackgroundReporting"];
}
if ((flags & NRFeatureFlag_AutoCollectLogs) == NRFeatureFlag_AutoCollectLogs) {
[retArray addObject:@"AutoCollectLogs"];
}

return retArray;
}
Expand Down
2 changes: 1 addition & 1 deletion Agent/Harvester/NRMAHarvester.mm
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ - (void) handleLoggingConfigurationUpdate {
// This if/else chain should only be entered if log_reporting was found in the config
if (configuration.has_log_reporting_config) {
if (configuration.log_reporting_enabled) {
if (![NewRelicInternalUtils isDebuggerAttached]){
if ([NRMAFlags shouldEnableAutoCollectLogs] && ![NewRelicInternalUtils isDebuggerAttached]){
[NRAutoLogCollector redirectStandardOutputAndError];
// it is required to enable NRLogTargetFile when using LogReporting.
[NRLogger setLogTargets:NRLogTargetFile];
Expand Down
1 change: 1 addition & 0 deletions Agent/Public/NewRelicFeatureFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,5 @@ typedef NS_OPTIONS(unsigned long long, NRMAFeatureFlags){
NRFeatureFlag_NewEventSystem = 1 << 20, // Disabled by default
NRFeatureFlag_OfflineStorage = 1 << 21, // Disabled by default
NRFeatureFlag_BackgroundReporting = 1 << 22, // Disabled by default
NRFeatureFlag_AutoCollectLogs = 1 << 23,
};

0 comments on commit 3b456c7

Please sign in to comment.