Swift中自定义Log
时间:2016-03-17 01:48:08
收藏:0
阅读:203
func XDLog<T>(message : T,file : String = __FILE__,funcName : String = __FUNCTION__,lineNum : Int = __LINE__){
#if DEBUG
//1.对文件进行处理
let fileName = (file as NSString).lastPathComponent
//2.打印内容
print("[\(fileName)]:[\(funcName)]: [\(lineNum)]:[\(message)] ")
#endif
//1.对文件进行处理
let fileName = (file as NSString).lastPathComponent
//2.打印内容
print("[\(fileName)]:[\(funcName)]: [\(lineNum)]:[\(message)] ")
#endif
}
配置文件

fileName 哪一个文件 funcName该文件的哪一个方法 lineNum 哪一行 message 额外想要打印的内容
1.拿到所在?文件:__FILE__
2.拿到所在?方法:__FUNCTION__
2.拿到所在?方法:__FUNCTION__
3.拿到所在?行号:__LINE__
只要调用XDLog即可
原文:http://www.cnblogs.com/wxdonly/p/5285809.html
评论(0)