Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Implemented different logLevel per each logger as suggested by @rivera-ernesto #151

Merged
merged 2 commits into from Nov 5, 2013

Conversation

Projects
None yet
5 participants
Member

bpoplauschi commented Nov 1, 2013

  • addLogger method new method with logLevel param
  • filtering via DDLoggerNode logLevel property
  • actual filtering inside lt_log

@ghost ghost assigned rivera-ernesto Nov 1, 2013

@bpoplauschi bpoplauschi Implemented different logLevel per each logger as suggested by @river…
…a-ernesto

- addLogger method new method with logLevel param
- filtering via DDLoggerNode logLevel property
- actual filtering inside lt_log
6fa2b6f
Member

rivera-ernesto commented Nov 5, 2013

I would like to merge this. Do you think you can do that small change to bpoplauschi/CocoaLumberjack@4310464#diff-cc127bbf3886b69e2c4a46bae5fff15bL185?

Member

bpoplauschi commented Nov 5, 2013

@rivera-ernesto I was making the change right now. Will be there in 2 minutes.

Member

bpoplauschi commented Nov 5, 2013

@rivera-ernesto It's updated. The previous solution was not wrong because inside addLogger: I was using the internal method lt_addLogger:logLevel:. But it order to keep the code clean, I made the update. Please review

@rivera-ernesto rivera-ernesto added a commit that referenced this pull request Nov 5, 2013

@rivera-ernesto rivera-ernesto Merge pull request #151 from bpoplauschi/loggerLogLevel
Implemented different logLevel per each logger as suggested by @rivera-ernesto
24f567c

@rivera-ernesto rivera-ernesto merged commit 24f567c into CocoaLumberjack:master Nov 5, 2013

Member

rivera-ernesto commented Nov 5, 2013

Nice. 1.6.3 should be close.

@bpoplauschi bpoplauschi deleted the bpoplauschi:loggerLogLevel branch Nov 5, 2013

dstd commented Nov 11, 2013

What is the reason to use separate array filteredLoggers ?
Isn't it better to filter in-place, like this:

                for (DDLoggerNode *loggerNode in loggers)
                {
                        if (logMessage->logFlag > loggerNode.logLevel)
                                continue;
                        dispatch_<.....>

Without any prefiltering.

Member

rivera-ernesto commented Nov 11, 2013

You're right and filteredLoggers is only used once. Could you make a pull request?

Hi,

Not sure if this is the correct place to raise this, but I could you check if 632 is causing an issue with XMPPLogging.h - explanation below.

The problem seems to be that the logFlag for XMPP_LOG_FLAG_SEND is always higher than the logLevel in

(void)lt_log:(DDLogMessage *)logMessage { ... if (logMessage->logFlag > loggerNode.logLevel) //see explanation below continue; ... }
So the log messages are skipped.

I'll try to explain...

In my XMPPStream.m I have defined:

if DEBUG

static const int xmppLogLevel = XMPP_LOG_FLAG_SEND; // | XMPP_LOG_FLAG_TRACE;

else

static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN;

endif

In XMPPLogging.h, XMPP_LOG_FLAG_SEND is pre-defined as:

define XMPP_LOG_FLAG_SEND (1 << 5) //32

In DDLog.m

A logger with a log level of LOG_LEVEL_VERBOSE, which is defined:

define LOG_FLAG_ERROR (1 << 0) // 0...00001

define LOG_FLAG_WARN (1 << 1) // 0...00010

define LOG_FLAG_INFO (1 << 2) // 0...00100

define LOG_FLAG_DEBUG (1 << 3) // 0...01000

define LOG_FLAG_VERBOSE (1 << 4) // 0...10000

define LOG_LEVEL_VERBOSE (LOG_FLAG_ERROR | LOG_FLAG_WARN | LOG_FLAG_INFO | LOG_FLAG_DEBUG | LOG_FLAG_VERBOSE) // 0...11111

And then added via this function:

(void)addLogger:(id )logger { [self addLogger:logger withLogLevel:LOG_LEVEL_VERBOSE]; NSLog(@"LOG_LEVEL_VERBOSE = %d", LOG_LEVEL_VERBOSE); }
This gives a total logLevel of 31.

Now in XMPPLogging.h we define XMPPLogSend as:

define XMPPLogSend(format, ...) XMPP_LOG_OBJC_MAYBE(XMPP_LOG_ASYNC_SEND, xmppLogLevel, \

XMPP_LOG_FLAG_SEND, XMPP_LOG_CONTEXT, format, ##VA_ARGS)

Which sends XMPP_LOG_FLAG_SEND which is defined as 32.

So when the below function is called, the logFlag (32) is never greater than the logLevel (31)

(void)lt_log:(DDLogMessage *)logMessage { ... if (logMessage->logFlag > loggerNode.logLevel) //see explanation below continue; ... }
Hope that makes sense.

Thanks

Michael

Member

dvor replied Dec 21, 2013

I've copied question to issue #196.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment