Skip to content

Commit

Permalink
Impl setLogEntityGuid
Browse files Browse the repository at this point in the history
  • Loading branch information
cdillard-NewRelic committed Dec 20, 2023
1 parent c6ba333 commit 3181b55
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Agent/Public/NRLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ typedef enum _NRLogTargets {
NSString *logURL;

NSString *logIngestKey;
NSString *logEntityGuid;

dispatch_queue_t logQueue;
unsigned long long lastFileSize;

Expand Down Expand Up @@ -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;

Expand Down
13 changes: 12 additions & 1 deletion Agent/Utilities/NRLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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}",
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 2 additions & 0 deletions Test Harness/NRTestApp/NRAPI-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<string></string>
<key>logIngestKey</key>
<string></string>
<key>logEntityGuid</key>
<string></string>
<key>NRAPIKey</key>
<string></string>
</dict>
Expand Down
7 changes: 7 additions & 0 deletions Test Harness/NRTestApp/NRTestApp/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 3181b55

Please sign in to comment.