robbiehanson/CocoaLumberjack — Issue #12: Adding new variable to 'DDLog' macro
Author: sgadhvi
Created: 2011-12-06 10:02:33+00:00
State: open

Hi robbiehanson,
Thank you very much for the great scalable utility. I have custom need in which I need to add tag with the formatted message, I already have added custom formatter ( MyFormatter) by confirming to DDLogFormatter.
The solution I see here is that I need to add new tag variable to DDLogMessage as each log is executed in separate thread.

OPTION 1: Add variable to DDLog call
Change the whole call sequence of all the macros.
For example if I want to make

DDLogVerbose(@"test");
as
DDLogVerbose(@"TAG",@"test");

I will need to add this extra variable to whole call sequence and all the other macros.
DDLogVerbose -> LOG_OBJC_MAYBE -> LOG_MAYBE -> LOG_MACRO ->[ DDLog log: ...];

OPTION 2: Add string variable to MyFormatter and change that variable before every DDLog call and in the 'formatLogMessage' I look for its value and customize the return string accordingly.
Problem here is all threads would manipulate this variable and will give inaccurate result.

OPTION 3: To add thread-safety to the variable discussed in OPTION 2. But, that would add performance hit.

So, do you see any quick solution to this, which would require less changes to the existing code??
Thanks in advance.