Skip to content

Commit 3181b55

Browse files
Impl setLogEntityGuid
1 parent c6ba333 commit 3181b55

File tree

4 files changed

+30
-2
lines changed

4 files changed

+30
-2
lines changed

Agent/Public/NRLogger.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ typedef enum _NRLogTargets {
9494
NSString *logURL;
9595

9696
NSString *logIngestKey;
97+
NSString *logEntityGuid;
98+
9799
dispatch_queue_t logQueue;
98100
unsigned long long lastFileSize;
99101

@@ -127,12 +129,18 @@ withMessage:(NSString *)message;
127129
+ (void)setLogTargets:(unsigned int)targets;
128130

129131
/*
130-
Configure the New Relic headerless logging API URL.
132+
Configure the New Relic logging API.
131133
132134
@param url A single NSString constant, the logging API URL.
133135
*/
134136
+ (void)setLogIngestKey:(NSString*) key;
135137

138+
/*
139+
Configure the New Relic logging API.
140+
141+
@param url A single NSString constant, the logging API URL.
142+
*/
143+
+ (void)setLogEntityGuid:(NSString*) key;
136144

137145
+ (void)setLogURL:(NSString*) url;
138146

Agent/Utilities/NRLogger.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ + (void)setLogIngestKey:(NSString*)key {
7272
[[NRLogger logger] setLogIngestKey:key];
7373
}
7474

75+
+ (void)setLogEntityGuid:(NSString*)key {
76+
[[NRLogger logger] setLogEntityGuid:key];
77+
}
78+
7579
+ (void)setLogURL:(NSString*) url {
7680
[[NRLogger logger] setLogURL:url];
7781

@@ -185,7 +189,9 @@ - (NSData*) jsonDictionary:(NSDictionary*)message {
185189
// TODO: Remove hardcoded entityId and Get this value from /connect response
186190
NSString* entityGuid = [NSString stringWithFormat:@"%@", configuration.entity_guid];
187191
if ([entityGuid length] == 0) {
188-
entityGuid = @"MTA4MTY5OTR8TU9CSUxFfEFQUExJQ0FUSU9OfDM5MDI3NDMz";
192+
if (logEntityGuid != nil) {
193+
entityGuid = logEntityGuid;
194+
}
189195
}
190196
// 1 2 3 4 5 6 7 8 9
191197
NSString* json = [NSString stringWithFormat:@"{ \n \"%@\":\"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\", \n \"%@\" : \"%@\"\n}",
@@ -312,6 +318,11 @@ - (void)clearLog {
312318
- (void)setLogIngestKey:(NSString*)url {
313319
self->logIngestKey = url;
314320
}
321+
322+
- (void)setLogEntityGuid:(NSString*)url {
323+
self->logEntityGuid = url;
324+
}
325+
315326
- (void)setLogURL:(NSString*)url {
316327
self->logURL = url;
317328
}

Test Harness/NRTestApp/NRAPI-Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
<string></string>
99
<key>logIngestKey</key>
1010
<string></string>
11+
<key>logEntityGuid</key>
12+
<string></string>
1113
<key>NRAPIKey</key>
1214
<string></string>
1315
</dict>

Test Harness/NRTestApp/NRTestApp/AppDelegate.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
8787
NewRelic.logInfo("NRLogger API uploading disabled. No URL given.")
8888
}
8989

90+
if let logEntityGuid = plistHelper.objectFor(key: "logEntityGuid", plist: "NRAPI-Info") as? String, !logEntityGuid.isEmpty {
91+
NRLogger.setLogEntityGuid(logEntityGuid)
92+
}
93+
else {
94+
NewRelic.logInfo("NRLogger API uploading disabled. No URL given.")
95+
}
96+
9097
NewRelic.logVerbose("NewRelic.start was called.")
9198
return true
9299
}

0 commit comments

Comments
 (0)