测试已测试 | ✗ |
语言语言 | SwiftSwift |
许可证 | MIT |
发布最后发布 | 2016 年 4 月 |
SPM支持 SPM | ✗ |
由hlandao 维护。
依赖项 | |
SnapKit | ~> 0.19.1 |
XCGLogger | ~> 3.3 |
请注意,此功能还会将日志记录到本地文件 - 仅在调试中使用
显示运行设备上的 XCGLogger 日志。
pod 'XCGLogger', '~> 3.3'
pod install
# 集成import SwiftLoggerInspector
。将 LoggerInspectorDestination
作为日志目标添加到您的 XCGLogger。
import XCGLogger
import SwiftLoggerInspector
...
var logger = XCGLogger.defaultInstance()
var loggerInspectorDestination: LoggerInspectorDestination!
loggerInspectorDestination = LoggerInspectorDestination(owner: logger, writeToFile: logFilePath())
logger.addLogDestination(loggerInspectorDestination)
loggerInspectorDestination.presentInspector()
。附加功能:在设备摇晃时显示检查器!
var logger = XCGLogger.defaultInstance()
var loggerInspectorDestination: LoggerInspectorDestination!
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
loggerInspectorDestination = LoggerInspectorDestination(owner: logger, writeToFile: logFilePath())
logger.addLogDestination(loggerInspectorDestination)
logger.debug("App delefate launched!")
return true
}
// Log file path url
func logFilePath() -> NSURL {
let urls = NSFileManager.defaultManager().URLsForDirectory(.CachesDirectory, inDomains: .UserDomainMask)
let url = urls[urls.endIndex - 1]
return url.URLByAppendingPathComponent("myLogFile.log")
}
// Detect shaking gesture
override func motionBegan(motion: UIEventSubtype,
withEvent event: UIEvent?) {
if motion == .MotionShake{
let logger = XCGLogger.defaultInstance()
if let loggerInspectorDestination = logger.logDestinations.last as? LoggerInspectorDestination {
loggerInspectorDestination.presentInspector()
}
}
}