我以前使用Objective C的Lumberjack记录器,我喜欢它。现在我开始学习Swift,我不能在那里使用我最喜欢的记录器。有人可以一步一步地写出我能做到的事吗?在Lumberjack 2.0发布之前,我尝试在这里找到一些东西,但所有主题都是自定义包装器。 我做了什么:
我不知道接下来该怎么办?因为在ObjC中我有宏:static const int ddLogLevel = LOG_LEVEL_INFO; else static const int ddLogLevel = LOG_LEVEL_VERBOSE;我的日志级别取决于编译标志......我可以在这里做吗? 以及如何在代码中使用Lumberjack?谢谢!
答案 0 :(得分: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
}
}
答案 1 :(得分:1)
如果您使用CocoaPods进行安装,请使用CocoaLumberjack/Swift
代替CocoaLumberjack
,如下所示:
pod 'CocoaLumberjack/Swift'