Skip to content

Commit

Permalink
Revert "NRLogger: Fix to honor remote log level and local log level c…
Browse files Browse the repository at this point in the history
…orrectly."

This reverts commit 28790a5.
  • Loading branch information
cdillard-NewRelic committed Oct 30, 2024
1 parent 28790a5 commit 7845059
Showing 1 changed file with 9 additions and 20 deletions.
29 changes: 9 additions & 20 deletions Agent/Utilities/NRLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ + (void)log:(unsigned int)level
// @synchronized(logger) {
shouldLog = (logger->logLevels & level) != 0;
// }

BOOL shouldRemoteLog = (logger->remoteLogLevel & level) != 0;


if (shouldLog || shouldRemoteLog) {

if (shouldLog) {
[logger addLogMessage:[NSDictionary dictionaryWithObjectsAndKeys:
[self levelToString:level], NRLogMessageLevelKey,
file, NRLogMessageFileKey,
Expand All @@ -83,10 +80,7 @@ + (void)log:(unsigned int)level
shouldLog = (logger->logLevels & level) != 0;
// }

BOOL shouldRemoteLog = (logger->remoteLogLevel & level) != 0;


if (shouldLog || shouldRemoteLog) {
if (shouldLog) {
NSMutableDictionary *mutableDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[self levelToString:level], NRLogMessageLevelKey,
file, NRLogMessageFileKey,
Expand All @@ -112,15 +106,13 @@ + (void)log:(unsigned int)level
// Filter passed logs by log level.
shouldLog = (logger->logLevels & level) != 0;

BOOL shouldRemoteLog = (logger->remoteLogLevel & level) != 0;

// Filtering of Console logs is performed based on logLevel.
// // If this is an agentLog, only print it if we are currently including the debug level.
// if (agentLogsOn) {
// shouldLog = (logger->logLevels & NRLogLevelDebug) != 0;
// }

if (shouldLog || shouldRemoteLog) {
if (shouldLog) {
[logger addLogMessage:[NSDictionary dictionaryWithObjectsAndKeys:
[self levelToString:level], NRLogMessageLevelKey,
file, NRLogMessageFileKey,
Expand Down Expand Up @@ -285,12 +277,7 @@ - (void)dealloc {
- (void)addLogMessage:(NSDictionary *)message : (BOOL) agentLogsOn {
// The static method checks the log level before we get here.
dispatch_async(logQueue, ^{

// Only enter this first block if local logging enabled.
NSString *levelString = [message objectForKey:NRLogMessageLevelKey];
NRLogLevels level = [NRLogger stringToLevel:levelString];
BOOL shouldLog = (self->logLevels & level) != 0;
if ((self->logTargets & NRLogTargetConsole) && shouldLog && (![NRMAFlags shouldEnableRedirectStdOut])) {
if ((self->logTargets & NRLogTargetConsole) && (![NRMAFlags shouldEnableRedirectStdOut])) {
NSLog(@"NewRelic(%@,%p):\t%@:%@\t%@\n\t%@",
[NewRelicInternalUtils agentVersion],
[NSThread currentThread],
Expand All @@ -300,10 +287,12 @@ - (void)addLogMessage:(NSDictionary *)message : (BOOL) agentLogsOn {
[message objectForKey:NRLogMessageMessageKey]);

}

// Only enter the second block if remote logging is including this messages level.
// Only enter this block if remote logging is including this messages level.
NSString *levelString = [message objectForKey:NRLogMessageLevelKey];
NRLogLevels level = [NRLogger stringToLevel:levelString];

BOOL shouldRemoteLog = (self->remoteLogLevel & level) != 0;

if (agentLogsOn) {
shouldRemoteLog = (self->remoteLogLevel & NRLogLevelDebug) != 0;
}
Expand Down

0 comments on commit 7845059

Please sign in to comment.