Swift51.com
Swift 头像
Swift  2016-05-30 23:08

Swift 日志框架 XCGLogger

回复:0  查看:6565  感兴趣:17  赞:0  

Swift 日志框架 XCGLogger

XCGLogger是一个debug日志框架,用于Swift项目中。允许您记录详细信息到控制台(还有一个可选的文件)。就像你用NSLog或println,但还有其他额处信息,如日期,函数名,文件名和行号。

示例代码:

import XCGLogger

let log = XCGLogger.defaultInstance()

//配置
log.setup(.Debug, showThreadName: true, showLogLevel: true, showFileNames: true, showLineNumbers: true, writeToFile: "path/to/file", fileLogLevel: .Debug)

log.verbose("A verbose message, usually useful when working on a specific problem")
log.debug("A debug message")
log.info("An info message, probably useful to power users looking in console.app")
log.warning("A warning message, may indicate a possible error")
log.error("An error occurred, but it's recoverable, just info about what happened")
log.severe("A severe error occurred, we are likely about to crash now")

相关开源代码