Skip to content

Commit 57c93a9

Browse files
committed
NR-318119 Renamed the flag to include stderr and changed the log divider to \n\n
1 parent 7fba9ba commit 57c93a9

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed

Agent/FeatureFlags/NRMAFlags.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ + (BOOL) shouldEnableBackgroundReporting {
178178
}
179179

180180
+ (BOOL) shouldEnableRedirectStdOut {
181-
return ([NRMAFlags featureFlags] & NRFeatureFlag_RedirectStdOut) != 0;
181+
return ([NRMAFlags featureFlags] & NRFeatureFlag_RedirectStdOutStdErr) != 0;
182182
}
183183

184184
+ (NSArray<NSString*>*) namesForFlags:(NRMAFeatureFlags)flags {
@@ -243,7 +243,7 @@ + (BOOL) shouldEnableRedirectStdOut {
243243
if ((flags & NRFeatureFlag_BackgroundReporting) == NRFeatureFlag_BackgroundReporting) {
244244
[retArray addObject:@"BackgroundReporting"];
245245
}
246-
if ((flags & NRFeatureFlag_RedirectStdOut) == NRFeatureFlag_RedirectStdOut) {
246+
if ((flags & NRFeatureFlag_RedirectStdOutStdErr) == NRFeatureFlag_RedirectStdOutStdErr) {
247247
[retArray addObject:@"RedirectStdOut"];
248248
}
249249

Agent/Public/NewRelicFeatureFlags.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ typedef NS_OPTIONS(unsigned long long, NRMAFeatureFlags){
102102
NRFeatureFlag_NewEventSystem = 1 << 20, // Disabled by default
103103
NRFeatureFlag_OfflineStorage = 1 << 21, // Disabled by default
104104
NRFeatureFlag_BackgroundReporting = 1 << 22, // Disabled by default
105-
NRFeatureFlag_RedirectStdOut = 1 << 23, // Disabled by default
105+
NRFeatureFlag_RedirectStdOutStdErr = 1 << 23, // Disabled by default
106106

107107
};

Agent/Utilities/NRAutoLogCollector.m

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ + (void) restoreStandardOutputAndError {
4949
dup2(saved_stderr, fileno(stderr));
5050
close(saved_stdout);
5151
close(saved_stderr);
52-
5352
}
5453

5554
+ (void) readAndParseLogFile {
@@ -65,16 +64,16 @@ + (void) readAndParseLogFile {
6564
NSString *fileContents = [NSString stringWithContentsOfFile:[NRAutoLogCollector logFileURL].path
6665
encoding:NSUTF8StringEncoding
6766
error:&error];
67+
[NRAutoLogCollector clearLogFile];
68+
6869
if (error) {
6970
return;
7071
} else if (fileContents.length == 0){
7172
return;
7273
}
7374

74-
[NRAutoLogCollector clearLogFile];
75-
7675
// Split the file contents into individual log entries
77-
NSArray<NSString *> *newLogEntries = [fileContents componentsSeparatedByString:@"\n"];
76+
NSArray<NSString *> *newLogEntries = [fileContents componentsSeparatedByString:@"\n\n"];
7877

7978
// Process each log entry
8079
for (NSString *logEntry in newLogEntries) {
@@ -129,11 +128,13 @@ + (unsigned int) extractType:(NSString *) inputString {
129128
// Extract the matched type value
130129
NSRange typeRange = [match rangeAtIndex:1];
131130
NSString *typeString = [inputString substringWithRange:typeRange];
132-
if([typeString compare:@"Info"] == NSOrderedSame || [typeString compare:@"Default"] == NSOrderedSame){
131+
if([typeString caseInsensitiveCompare:@"Info"] == NSOrderedSame || [typeString caseInsensitiveCompare:@"Default"] == NSOrderedSame){
133132
return NRLogLevelInfo;
134-
} else if([typeString compare:@"Debug"] == NSOrderedSame){
133+
} else if([typeString caseInsensitiveCompare:@"Debug"] == NSOrderedSame){
135134
return NRLogLevelDebug;
136-
} else if([typeString compare:@"Error"] == NSOrderedSame || [typeString compare:@"Fault"] == NSOrderedSame){
135+
} else if([typeString caseInsensitiveCompare:@"Warning"] == NSOrderedSame){
136+
return NRLogLevelWarning;
137+
} else if([typeString caseInsensitiveCompare:@"Error"] == NSOrderedSame || [typeString caseInsensitiveCompare:@"Fault"] == NSOrderedSame){
137138
return NRLogLevelError;
138139
}
139140
}

Test Harness/NRTestApp/NRTestApp/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
3535
// NewRelic.enableFeatures([NRMAFeatureFlags.NRFeatureFlag_BackgroundReporting])
3636

3737
// Note: Disabled by default. Enable or disable (default) flag to enable auto collect of stdout.
38-
// NewRelic.enableFeatures([NRMAFeatureFlags.NRFeatureFlag_RedirectStdOut])
38+
//NewRelic.enableFeatures([NRMAFeatureFlags.NRFeatureFlag_RedirectStdOutStdErr])
3939
NewRelic.saltDeviceUUID(true)
4040

4141
// NewRelic.replaceDeviceIdentifier("myDeviceId")

Test Harness/NRTestApp/NRTestApp/ViewModels/UtilViewModel.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class UtilViewModel {
161161
func testSystemLogs() {
162162
for i in 0...100 {
163163
triggerException.testNSLog()
164-
print("TEST swift!!!!! \(i)")
164+
print("TEST swift!!!!! \(i)\n")
165165
if #available(iOS 14.0, *) {
166166
os_log("TEST OSLog!!!!!!! \(i)")
167167
let logger = Logger()

0 commit comments

Comments
 (0)