自定义打印

在公开文件中添加以下定义:
func XFLog(message : T, file : String = #file, lineNumber : Int = #line) {
#if DEBUG
let fileName = (file as NSString).lastPathComponent
print("\(String.init(format:"%.6f", CFAbsoluteTimeGetCurrent()))- [\(fileName) line:\(String.init(format:"%04d", lineNumber))]- \(message)")
#endif
}


使用:
XFLog(message: "time out")




【自定义打印】思考:自定义打印级别

    推荐阅读