Global log level for CocoaLumberjack

后端 未结 12 920
[愿得一人]
[愿得一人] 2020-12-23 20:19

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

12条回答
  •  有刺的猬
    2020-12-23 20:48

    I didn't find a better way to do it than the one explained in the article I mentioned in the question.

    Constant.h

    extern int const ddLogLevel;
    

    Constant.m

    #import "Constants.h"
    #import "DDLog.h"
    
    int const ddLogLevel = LOG_LEVEL_VERBOSE;
    

    Logger configuration

    #import "DDLog.h"
    #import "DDASLLogger.h"
    #import "DDTTYLogger.h"
    #import "DDFileLogger.h"
    
    ...
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
     [DDLog addLogger:[DDASLLogger sharedInstance]];
     [DDLog addLogger:[DDTTYLogger sharedInstance]];
    
     DDFileLogger *fileLogger = [[DDFileLogger alloc] init]; 
     [DDLog addLogger:fileLogger];
     [fileLogger release];
    
    ...
    

    Import your class

    #import "DDLog.h"
    #import "Constants.h"
    
    ...
    
    - (void)someMethod {
     DDLogVerbose(@"Log this message");
    }
    

提交回复
热议问题