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
}
配置文件
![](https://images2015.cnblogs.com/blog/818608/201603/818608-20160317001412974-227779585.png)
fileName 哪一个文件 funcName该文件的哪一个方法 lineNum 哪一行 message 额外想要打印的内容
1.拿到所在⽂文件:__FILE__
2.拿到所在⽅方法:__FUNCTION__
2.拿到所在⽅方法:__FUNCTION__
3.拿到所在⾏行号:__LINE__
只要调用XDLog即可