robbiehanson / XMPPFramework

An XMPP Framework in Objective-C for Mac and iOS
Other
5.91k stars 2.09k forks source link

XMPPStream did not logging xml string #284

Closed haithngnbak closed 10 years ago

haithngnbak commented 10 years ago

Hi, I used default logging flag : // Log levels: off, error, warn, info, verbose

if DEBUG

static const int xmppLogLevel = XMPP_LOG_LEVEL_INFO | XMPP_LOG_FLAG_SEND_RECV | XMPP_LOG_FLAG_VERBOSE; // | XMPP_LOG_FLAG_TRACE;

else

static const int xmppLogLevel = XMPP_LOG_LEVEL_WARN;

endif

but the code bellow did not logging xml string: XMPPLogTrace(); XMPPLogRecvPost(@"RECV: %@", [root compactXMLString]);

Please help me fix this Thanks,

ObjColumnist commented 10 years ago

Do you have the DEBUG Preprocessor Macro? screen shot 2013-12-18 at 09 43 10

haithngnbak commented 10 years ago

https://lh3.googleusercontent.com/-iCWd2NnQ2tE/UrJicSoO-JI/AAAAAAAAAVg/w_5EVO_CD8w/w799-h113-no/Screen+Shot+2013-12-19+at+10.04.04+AM.png sure, bit it still does not work,

mreaybeaton commented 10 years ago

Hi,

I might be able to add to this - I've been seeing the same sort of issue, i.e. no output from XMPPLogSend(@"SEND: %@", s1).

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

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:

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)

Hope that makes sense.

Thanks

Michael

ObjColumnist commented 10 years ago

Do you get the logs with the iPhone sample project?

mreaybeaton commented 10 years ago

Yes I do - however the code in DDLog.m is different to the version that I use in cocoapods (CocoaLumberjack (1.6.5.1))