@@ -36,13 +36,13 @@ - (void) setUp
36
36
[NRLogger setLogEntityGuid: @" Entity-Guid-XXXX" ];
37
37
38
38
NRMAAgentConfiguration *config = [[NRMAAgentConfiguration alloc ] initWithAppToken: [[NRMAAppToken alloc ] initWithApplicationToken: kNRMA_ENABLED_STAGING_APP_TOKEN ]
39
- collectorAddress: KNRMA_TEST_COLLECTOR_HOST
40
- crashAddress: nil ];
39
+ collectorAddress: KNRMA_TEST_COLLECTOR_HOST
40
+ crashAddress: nil ];
41
41
[NRMAHarvestController initialize: config];
42
42
43
43
category = @" hello" ;
44
44
name = @" world" ;
45
-
45
+
46
46
helper = [[NRMAMeasurementConsumerHelper alloc ] initWithType: NRMAMT_NamedValue];
47
47
48
48
[NRMAMeasurements initializeMeasurements ];
@@ -102,16 +102,20 @@ - (void) testNRLogger {
102
102
XCTFail (@" Timeout error" );
103
103
}
104
104
}];
105
-
105
+
106
+ NSError * error;
106
107
NSString *path = [NRLogger logFilePath ];
107
- NSData * logData = [NSData dataWithContentsOfFile: path];
108
+ NSData * logData = [NRLogger logFileData: &error];
109
+ if (error){
110
+ NSLog (@" %@ " , error.localizedDescription );
111
+ }
108
112
109
113
NSString * logMessagesJson = [NSString stringWithFormat: @" [ %@ ]" , [[NSString alloc ] initWithData: logData encoding: NSUTF8StringEncoding]];
110
114
NSData * formattedData = [logMessagesJson dataUsingEncoding: NSUTF8StringEncoding];
111
115
112
116
NSArray * decode = [NSJSONSerialization JSONObjectWithData: formattedData
113
- options: 0
114
- error: nil ];
117
+ options: 0
118
+ error: nil ];
115
119
NSLog (@" decode=%@ " , decode);
116
120
117
121
NSArray * expectedValues = @[
@@ -134,6 +138,20 @@ - (void) testNRLogger {
134
138
if ([[dict2 objectForKey: @" message" ] isEqualToString: currentMessage]) {
135
139
foundCount += 1 ;
136
140
XCTAssertTrue ([[dict2 objectForKey: @" entity.guid" ] isEqualToString: @" Entity-Guid-XXXX" ],@" entity.guid set incorrectly" );
141
+ XCTAssertTrue ([[dict2 objectForKey: NRLogMessageInstrumentationProviderKey] isEqualToString: NRLogMessageMobileValue],@" instrumentation provider set incorrectly" );
142
+ XCTAssertTrue ([[dict2 objectForKey: NRLogMessageInstrumentationVersionKey] isEqualToString: @" DEV" ],@" instrumentation name set incorrectly" );
143
+
144
+ #if TARGET_OS_WATCH
145
+ XCTAssertTrue ([[dict2 objectForKey: NRLogMessageInstrumentationNameKey] isEqualToString: @" watchOSAgent" ],@" instrumentation name set incorrectly" );
146
+ #else
147
+ if ([[[UIDevice currentDevice ] systemName ] isEqualToString: @" tvOS" ]) {
148
+ XCTAssertTrue ([[dict2 objectForKey: NRLogMessageInstrumentationNameKey] isEqualToString: @" tvOSAgent" ],@" instrumentation name set incorrectly" );
149
+
150
+ }
151
+ else {
152
+ XCTAssertTrue ([[dict2 objectForKey: NRLogMessageInstrumentationNameKey] isEqualToString: @" iOSAgent" ],@" instrumentation name set incorrectly" );
153
+ }
154
+ #endif
137
155
}
138
156
// Verify added attributes with logAttributes.
139
157
if ([[dict2 objectForKey: @" message" ] isEqualToString: @" This is a test message for the New Relic logging system." ]) {
@@ -148,7 +166,7 @@ - (void) testNRLogger {
148
166
149
167
150
168
- (void ) testRemoteLogLevels {
151
-
169
+
152
170
// Set the remote log level to warning.
153
171
[NRLogger setRemoteLogLevel: NRLogLevelWarning];
154
172
@@ -163,7 +181,7 @@ - (void) testRemoteLogLevels {
163
181
XCTFail (@" Timeout error" );
164
182
}
165
183
}];
166
-
184
+
167
185
// Three messages should reach the remote log file for upload.
168
186
169
187
[NewRelic logInfo: @" Info Log..." ];
@@ -199,8 +217,8 @@ - (void) testRemoteLogLevels {
199
217
NSString * logMessagesJson = [NSString stringWithFormat: @" [ %@ ]" , [[NSString alloc ] initWithData: logData encoding: NSUTF8StringEncoding]];
200
218
NSData * formattedData = [logMessagesJson dataUsingEncoding: NSUTF8StringEncoding];
201
219
NSArray * decode = [NSJSONSerialization JSONObjectWithData: formattedData
202
- options: 0
203
- error: nil ];
220
+ options: 0
221
+ error: nil ];
204
222
NSLog (@" decode=%@ " , decode);
205
223
206
224
NSArray * expectedValues = @[
0 commit comments