Skip to content

Commit

Permalink
Log attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
cdillard-NewRelic committed Apr 19, 2024
1 parent 9e2fa56 commit b4814ee
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Agent/Analytics/PersistentEventStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ - (void)setObject:(nonnull id)object forKey:(nonnull id)key {
@synchronized (store) {
store[key] = object;
_dirty = YES;
NRLOG_VERBOSE(@"Marked dirty for adding");
NRLOG_AUDIT(@"Marked dirty for adding");
}

NRLOG_VERBOSE(@"Scheduling block");
NRLOG_AUDIT(@"Scheduling block");
[self performWrite: ^ {
NRLOG_VERBOSE(@"Entered block");
NRLOG_AUDIT(@"Entered block");
@synchronized (self) {
if(!self->_dirty) {
NRLOG_VERBOSE(@"Not writing file because it's not dirty");
NRLOG_AUDIT(@"Not writing file because it's not dirty");
return;
}
}
Expand Down Expand Up @@ -157,7 +157,7 @@ - (void)saveToFile {
if(!success) {
NRLOG_ERROR(@"Error saving data: %@", error.description);
} else {
NRLOG_VERBOSE(@"Wrote file");
NRLOG_AUDIT(@"Wrote file");
_lastSave = [NSDate new];
}
}
Expand Down
17 changes: 17 additions & 0 deletions Test Harness/NRTestApp/NRTestApp/ViewModels/UtilViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class UtilViewModel {
options.append(UtilOption(title: "Notice Network Failure", handler: { [self] in noticeFailedNWRequest()}))

options.append(UtilOption(title: "Test Log Dict", handler: { [self] in testLogDict()}))
options.append(UtilOption(title: "Test Log Error", handler: { [self] in testLogError()}))
options.append(UtilOption(title: "Test Log Attributes", handler: { [self] in testLogAttributes()}))

options.append(UtilOption(title: "Make 100 Logs", handler: { [self] in make100Logs()}))
options.append(UtilOption(title: "Make 100 Special Character Logs", handler: { [self] in make100SpecialCharacterLogs()}))
Expand Down Expand Up @@ -138,7 +140,22 @@ class UtilViewModel {
"message": "This is a test message for the New Relic logging system."
])
}
func testLogError() {

do {
try errorMethod()
} catch {
NewRelic.logErrorObject(error)
}
}

// TODO: Wrap up attributes handling as a part of NR-227300
func testLogAttributes() {
NewRelic.logAttributes([
"logLevel": "WARN",
"message": "This is a test message for the New Relic logging system."
])
}


func noticeNWRequest() {
Expand Down

0 comments on commit b4814ee

Please sign in to comment.