Lumberjack 2.0 Logger with Swift

I used the Lumberjack logger with Objective-C and I like it. Now I'm starting to learn Swift, and I can’t use my favorite magazine. Can someone write step by step how can I do this, please? I'm trying to find something here, but all the themes are old with custom wrappers, before the release of Lumberjack 2.0. What I've done:

  • I added Lumberjack with Cocoapods;
  • I added "#import" to the Bridging-Header file.

And I don’t know what to do next? Because in ObjC I had macros: static const int ddLogLevel = LOG_LEVEL_INFO; else static const int ddLogLevel = LOG_LEVEL_VERBOSE; and my log level depends on the compilation flag ... Can I do it here? And how to use Lumberjack in code? Thanks!

+7
ios logging swift lumberjack cocoalumberjack
source share
2 answers

If you are installing CocoaPods, use CocoaLumberjack/Swift instead of CocoaLumberjack , for example:

 pod 'CocoaLumberjack/Swift' 
+1
source share

Please refer to the GitHub issue below as it explains how to solve problems when integrating the Swift framework. In addition, you can refer to the example below (taken from the flow of problems), which is very useful.

https://github.com/CocoaLumberjack/CocoaLumberjack/issues/405

 @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for customization after application launch. let formatter = Formatter() DDTTYLogger.sharedInstance().logFormatter = formatter DDLog.addLogger(DDTTYLogger.sharedInstance()) DDLogVerbose("Verbose"); DDLogDebug("Debug"); DDLogInfo("Info"); DDLogWarn("Warn"); DDLogError("Error"); printSomething() defaultDebugLevel = ddloglevel printSomething() return true } } 
0
source share

All Articles