NSLogger
NSLogger copied to clipboard
Allow thread information to be passed in externally (Integration w/ CocoaLumberjack)
When using CocoaLumberjack (or other logging frameworks) on top of NSLogger (see https://github.com/0xced/XCDLumberjackNSLogger/blob/develop/XCDLumberjackNSLogger.m), the threading information is no longer correct.

If we allow threading information to be passed in (DDLogMessage contains threadName info, http://cocoadocs.org/docsets/CocoaLumberjack/1.6/Classes/DDLogMessage.html#//api/name/threadID), it will make the NSLogger display much more useful when integrated with other logging frameworks.
Good idea, although this will require yet another set of APIs
@tonyxiao If you are using XCDLumberjackNSLogger 1.0.1 or later then you should have correct threading information. But of course, as mentioned in a comment, XCDLumberjackNSLogger abuses NSLogger’s thread name caching mechanism and a proper set of new APIs would be a better solution.
Oh that's neat! I am not using XCDLumberjackNSLogger but I'll certainly be using a similar approach to hack around the issue for now.
Reference:
static void SetThreadNameWithMessage(DDLogMessage *logMessage)
{
// There is no _thread name_ parameter for LogXXXToF functions, but we can abuse NSLogger’s thread name caching mechanism which uses the current thread dictionary
NSString *queueLabel = [logMessage.queueLabel isEqualToString:@"com.apple.main-thread"] ? @"Main Queue" : logMessage.queueLabel;
NSThread.currentThread.threadDictionary[@"__$NSLoggerThreadName$__"] = [NSString stringWithFormat:@"%@ [%@]", logMessage.threadID, queueLabel];
}