CocoaLumberjack with Swift - Calling preprocessor macros

后端 未结 3 1723
鱼传尺愫
鱼传尺愫 2020-12-28 10:32

I started to build an IOS app with the new programming language Swift. I managed to use CocoaPods and was able to successfully create the DDTTYLogger with my CustomLoggerFor

3条回答
  •  别那么骄傲
    2020-12-28 11:16

    As of 2.0.0beta4, CocoaLumberJack includes a CocoaLumberJack.swift file that makes its integration with Swift projects really easily.

    They use a global var defaultDebugLevel to set the DDLogLevel, and you can swift basic precompile macros to customize it to your needs.

    #if DEBUG
        defaultDebugLevel = DDLogLevel.All
    #else
        defaultDebugLevel = DDLogLevel.Warning
    #endif
    
    DDLog.addLogger(DDTTYLogger.sharedInstance())
    DDLogDebug("Debug")
    DDLogInfo("Info")
    DDLogWarn("Warning")
    DDLogVerbose("Verbose")
    DDLogError("Error")
    

提交回复
热议问题