diff --git a/Agent/Public/NRLogger.h b/Agent/Public/NRLogger.h index b1736af2..cc619cf6 100644 --- a/Agent/Public/NRLogger.h +++ b/Agent/Public/NRLogger.h @@ -94,6 +94,8 @@ typedef enum _NRLogTargets { NSString *logURL; NSString *logIngestKey; + NSString *logEntityGuid; + dispatch_queue_t logQueue; unsigned long long lastFileSize; @@ -127,12 +129,18 @@ withMessage:(NSString *)message; + (void)setLogTargets:(unsigned int)targets; /* -Configure the New Relic headerless logging API URL. +Configure the New Relic logging API. @param url A single NSString constant, the logging API URL. */ + (void)setLogIngestKey:(NSString*) key; +/* + Configure the New Relic logging API. + +@param url A single NSString constant, the logging API URL. +*/ ++ (void)setLogEntityGuid:(NSString*) key; + (void)setLogURL:(NSString*) url; diff --git a/Agent/Utilities/NRLogger.m b/Agent/Utilities/NRLogger.m index f5d0af8d..0eacea53 100644 --- a/Agent/Utilities/NRLogger.m +++ b/Agent/Utilities/NRLogger.m @@ -72,6 +72,10 @@ + (void)setLogIngestKey:(NSString*)key { [[NRLogger logger] setLogIngestKey:key]; } ++ (void)setLogEntityGuid:(NSString*)key { + [[NRLogger logger] setLogEntityGuid:key]; +} + + (void)setLogURL:(NSString*) url { [[NRLogger logger] setLogURL:url]; @@ -185,7 +189,9 @@ - (NSData*) jsonDictionary:(NSDictionary*)message { // TODO: Remove hardcoded entityId and Get this value from /connect response NSString* entityGuid = [NSString stringWithFormat:@"%@", configuration.entity_guid]; if ([entityGuid length] == 0) { - entityGuid = @"MTA4MTY5OTR8TU9CSUxFfEFQUExJQ0FUSU9OfDM5MDI3NDMz"; + if (logEntityGuid != nil) { + entityGuid = logEntityGuid; + } } // 1 2 3 4 5 6 7 8 9 NSString* json = [NSString stringWithFormat:@"{ \n \"%@\":\"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\",\n \"%@\" : \"%@\", \n \"%@\" : \"%@\"\n}", @@ -312,6 +318,11 @@ - (void)clearLog { - (void)setLogIngestKey:(NSString*)url { self->logIngestKey = url; } + +- (void)setLogEntityGuid:(NSString*)url { + self->logEntityGuid = url; +} + - (void)setLogURL:(NSString*)url { self->logURL = url; } diff --git a/Test Harness/NRTestApp/NRAPI-Info.plist b/Test Harness/NRTestApp/NRAPI-Info.plist index 66c5028e..7cdb5465 100644 --- a/Test Harness/NRTestApp/NRAPI-Info.plist +++ b/Test Harness/NRTestApp/NRAPI-Info.plist @@ -8,6 +8,8 @@ logIngestKey + logEntityGuid + NRAPIKey diff --git a/Test Harness/NRTestApp/NRTestApp/AppDelegate.swift b/Test Harness/NRTestApp/NRTestApp/AppDelegate.swift index 72f01fd7..9e6817c0 100644 --- a/Test Harness/NRTestApp/NRTestApp/AppDelegate.swift +++ b/Test Harness/NRTestApp/NRTestApp/AppDelegate.swift @@ -87,6 +87,13 @@ class AppDelegate: UIResponder, UIApplicationDelegate { NewRelic.logInfo("NRLogger API uploading disabled. No URL given.") } + if let logEntityGuid = plistHelper.objectFor(key: "logEntityGuid", plist: "NRAPI-Info") as? String, !logEntityGuid.isEmpty { + NRLogger.setLogEntityGuid(logEntityGuid) + } + else { + NewRelic.logInfo("NRLogger API uploading disabled. No URL given.") + } + NewRelic.logVerbose("NewRelic.start was called.") return true }