原简书地址:http://www.jianshu.com/p/9c88380c24e6
OC :
#if DEBUG
#ifndef DLog
#define DLog(format, args...) \
NSLog(@"[%s:%d]: " format "\n", strrchr(__FILE__, '/') + 1, __LINE__, ## args);
#endif
#else
#ifndef DLog
#define DLog(format, args...) do {} while(0)
#endif
#endif
SWIFT
func DLog(items: String, function: Int32 = __LINE__,file:String = __FILE__) {
#if DEBUG
let className = String.fromCString(strrchr(file, Int32(("/".cStringUsingEncoding(NSUTF8StringEncoding)?.first)!))+1)!
print("-[\(className):\(function)]: \(items)")
#endif
}