FKConsole 1.0.1

FKConsole 1.0.1

测试已测试
Lang语言 SwiftSwift
许可证 MIT
发布最后发布2016年12月
SwiftSwift 版本3.0
SPM支持 SPM

FlyKite 维护。



FKConsole 1.0.1

FKConsole

一个便利的控制台视图

特性

  • [x] 使用简单
  • [x] 调试方便
  • [x] 无需更改关键窗口
  • [x] 容易区分不同的日志级别
  • [x] 记录包含类和函数信息,项目内易于查找

需求

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.")

example

许可证

所有源代码均按 MIT 许可证授权。