XCGLogger是一個debug日志框架,用于Swift項(xiàng)目中。允許您記錄詳細(xì)信息到控制臺(還有一個可選的文件)。就像你用NSLog或println,但還有其他額處信息,如日期,函數(shù)名,文件名和行號。
示例代碼:
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")