I\'m using CocoaLumberjack in an iPhone project, to log some information.
I\'ve followed the Getting started guide, and everything works fine, but there is one thing
In order to dynamically inject log level (for example, from configuration file):
1) Create a new class named DDLogLevel with the following code:
#import "DDLogLevel.h"
#import "DDLog.h"
@implementation DDLogLevel
static int _ddLogLevel = LOG_LEVEL_VERBOSE;
+ (int)ddLogLevel
{
return _ddLogLevel;
}
+ (void)ddSetLogLevel:(int)logLevel
{
_ddLogLevel = logLevel;
}
@end
2) In DDLogLevel.h, find the row that contains the following statement:
#ifndef LOG_LEVEL_DEF
#define LOG_LEVEL_DEF ddLogLevel
#endif
And replace it with:
#ifndef LOG_LEVEL_DEF
#define LOG_LEVEL_DEF [DDLogLevel ddLogLevel]
#endif
3) Finally, call from your Initialization process (perhaps from appDelegate) to ddSetLogLevel with the desired level.