测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2016年12月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 FlyKite 维护。
一个便利的控制台视图
iOS 8.0 或更高版本
Swift 3.0 或更高版本
手动操作: 将 FKConsole.swift 复制到您的项目中
CocoaPods: pod 'FKConsole'
首先,在 AppDelegate 中注册 FKConsole。
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
// register FKConsole with default gesture (Double tap with three fingers to toggle)
FKConsole.register(window: self.window)
// Register FKConsole with custom gesture
/*
let showGesture = UITapGestureRecognizer.init()
showGesture.numberOfTapsRequired = 2
showGesture.numberOfTouchesRequired = 3
let hideGesture = UILongPressGestureRecognizer.init()
hideGesture.minimumPressDuration = 1.0
hideGesture.numberOfTouchesRequired = 3
FKConsole.register(window: window, showGesture: showGesture, hideGesture: hideGesture)
*/
return true
}
然后您可以使用以下函数打印日志。
/// Override to intercept print method
/// It's not recommended, please use Log.v(xxx) instead.
/// If you don't want to use this method, please remove it.
public func print(_ items: Any...)
public class Log: NSObject {
/// Print verbose log (white)
///
/// - parameter log: log content string
public class func v(_ log: String?, fileName: String = #file, function: String = #function, lineNumber: Int = #line)
/// Print debug log (blue)
///
/// - parameter log: log content string
public class func d(_ log: String?, fileName: String = #file, function: String = #function, lineNumber: Int = #line)
/// Print info log (green)
///
/// - parameter log: log content string
public class func i(_ log: String?, fileName: String = #file, function: String = #function, lineNumber: Int = #line)
/// Print warning log (yellow)
///
/// - parameter log: log content string
public class func w(_ log: String?, fileName: String = #file, function: String = #function, lineNumber: Int = #line)
/// Print error log (red)
///
/// - parameter log: log content string
public class func e(_ log: String?, fileName: String = #file, function: String = #function, lineNumber: Int = #line)
}
注意:不建议使用打印函数!它不会打印您调用 print()
的类和函数。
print("Print a verbose log.")
Log.v("This is a verbose log.")
Log.d("This is a debug log.")
Log.i("This is a info log.")
Log.w("This is a warning log.")
Log.e("This is a error log.")
所有源代码均按 MIT 许可证授权。