swift中自定義log輸出日志,swift支持全局函數(shù)栅隐,不寫在任何類中的方法可以當(dāng)做全局方法使用盏触。這里寫在了Appdelegate.swift文件中:
func toolLog<T>(message : T,file: String = #file, funcName: String = #function, lineNum : Int = #line) {
#if DEBUG
// let fileName = (file as String);
print("函數(shù):\(funcName)-行:\(lineNum)-\(message)");
#endif
}
因?yàn)樵趕wift中沒有宏定義的概念,添加截圖所示
其他要打印的內(nèi)容可以自行添加