Skip to content

Commit 7845059

Browse files
Revert "NRLogger: Fix to honor remote log level and local log level correctly."
This reverts commit 28790a5.
1 parent 28790a5 commit 7845059

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

Agent/Utilities/NRLogger.m

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,8 @@ + (void)log:(unsigned int)level
5252
// @synchronized(logger) {
5353
shouldLog = (logger->logLevels & level) != 0;
5454
// }
55-
56-
BOOL shouldRemoteLog = (logger->remoteLogLevel & level) != 0;
57-
58-
59-
if (shouldLog || shouldRemoteLog) {
55+
56+
if (shouldLog) {
6057
[logger addLogMessage:[NSDictionary dictionaryWithObjectsAndKeys:
6158
[self levelToString:level], NRLogMessageLevelKey,
6259
file, NRLogMessageFileKey,
@@ -83,10 +80,7 @@ + (void)log:(unsigned int)level
8380
shouldLog = (logger->logLevels & level) != 0;
8481
// }
8582

86-
BOOL shouldRemoteLog = (logger->remoteLogLevel & level) != 0;
87-
88-
89-
if (shouldLog || shouldRemoteLog) {
83+
if (shouldLog) {
9084
NSMutableDictionary *mutableDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
9185
[self levelToString:level], NRLogMessageLevelKey,
9286
file, NRLogMessageFileKey,
@@ -112,15 +106,13 @@ + (void)log:(unsigned int)level
112106
// Filter passed logs by log level.
113107
shouldLog = (logger->logLevels & level) != 0;
114108

115-
BOOL shouldRemoteLog = (logger->remoteLogLevel & level) != 0;
116-
117109
// Filtering of Console logs is performed based on logLevel.
118110
// // If this is an agentLog, only print it if we are currently including the debug level.
119111
// if (agentLogsOn) {
120112
// shouldLog = (logger->logLevels & NRLogLevelDebug) != 0;
121113
// }
122114

123-
if (shouldLog || shouldRemoteLog) {
115+
if (shouldLog) {
124116
[logger addLogMessage:[NSDictionary dictionaryWithObjectsAndKeys:
125117
[self levelToString:level], NRLogMessageLevelKey,
126118
file, NRLogMessageFileKey,
@@ -285,12 +277,7 @@ - (void)dealloc {
285277
- (void)addLogMessage:(NSDictionary *)message : (BOOL) agentLogsOn {
286278
// The static method checks the log level before we get here.
287279
dispatch_async(logQueue, ^{
288-
289-
// Only enter this first block if local logging enabled.
290-
NSString *levelString = [message objectForKey:NRLogMessageLevelKey];
291-
NRLogLevels level = [NRLogger stringToLevel:levelString];
292-
BOOL shouldLog = (self->logLevels & level) != 0;
293-
if ((self->logTargets & NRLogTargetConsole) && shouldLog && (![NRMAFlags shouldEnableRedirectStdOut])) {
280+
if ((self->logTargets & NRLogTargetConsole) && (![NRMAFlags shouldEnableRedirectStdOut])) {
294281
NSLog(@"NewRelic(%@,%p):\t%@:%@\t%@\n\t%@",
295282
[NewRelicInternalUtils agentVersion],
296283
[NSThread currentThread],
@@ -300,10 +287,12 @@ - (void)addLogMessage:(NSDictionary *)message : (BOOL) agentLogsOn {
300287
[message objectForKey:NRLogMessageMessageKey]);
301288

302289
}
303-
304-
// Only enter the second block if remote logging is including this messages level.
290+
// Only enter this block if remote logging is including this messages level.
291+
NSString *levelString = [message objectForKey:NRLogMessageLevelKey];
292+
NRLogLevels level = [NRLogger stringToLevel:levelString];
305293

306294
BOOL shouldRemoteLog = (self->remoteLogLevel & level) != 0;
295+
307296
if (agentLogsOn) {
308297
shouldRemoteLog = (self->remoteLogLevel & NRLogLevelDebug) != 0;
309298
}

0 commit comments

Comments
 (0)