use*_*622 7 logging ios lumberjack swift cocoalumberjack
我以前使用物镜C的Lumberjack记录器,我喜欢它.现在我开始学习Swift,我不能在那里使用我最喜欢的记录器.有人可以一步一步地写出我能做到的事吗?在Lumberjack 2.0发布之前,我尝试在这里找到一些东西,但所有主题都是自定义包装器.我做了什么:
我不知道接下来该怎么办?因为在ObjC中我有宏:static const int ddLogLevel = LOG_LEVEL_INFO; else static const int ddLogLevel = LOG_LEVEL_VERBOSE; 我的日志级别取决于编译标志......我可以在这里做吗?以及如何在代码中使用Lumberjack?谢谢!
小智 1
请参阅 GitHub 上的以下问题,它解释了如何在集成 Swift 框架时解决问题。另外,您可以参考下面的示例(取自问题线程),这非常有帮助。
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
}
}
Run Code Online (Sandbox Code Playgroud)