EPLogger
使用
- 在您的
AppDelegate.swift
中导入import EPLogger
- 将
public typealias Log = EPLogger.Log
复制粘贴到您的AppDelegate.swift
顶部 - 在
AppDelegate.didFinishLaunchingWithOptions
方法中设置日志级别 - 完成!
更详细的信息,请参阅 示例
示例
import UIKit
import EPLogger
// If you want to get import once and use it globally
public typealias Log = EPLogger.Log
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Set log level. default is verbose
Log.config(level: .verbose)
Log.verbose("This is verbose")
Log.debug("This is debug")
Log.info("This is info")
Log.warning("This is warning")
Log.error("This is error")
return true
)
}
输出将如下所示
要求
Swift 5.0
安装
EPLogger 通过 CocoaPods 提供。要安装它,只需将以下行添加到 Podfile 中
pod 'EPLogger'
同时也支持 Carthage
只需将以下行添加到 Cartfile 中
github "ElonPark/EPLogger"
作者
伊隆·帕克,[email protected]
许可证
EPLogger遵守MIT许可证。详细信息请参阅LICENSE文件。