swift:定制打印输出代替print

想要的打印效果 **<10:39:29 LEWebViewController.swift:72>-:deinit**
    /** 代替Swift的 print打印 */
func LE_NSLog(message: AnyObject, file: String = #file, function: String = #function, lineNum: Int = #line) {
#if LE_DEBUG
let interval = NSTimeZone.systemTimeZone().secondsFromGMTForDate(NSDate())
let date = NSDate().dateByAddingTimeInterval(Double(interval))
let dateStr = String(date)
let subStr = (dateStr as NSString).substringWithRange(NSMakeRange(11, 8))

print("<\(subStr) \((file as NSString).pathComponents.last!):\(lineNum)>-:\(message)")
#endif
}
swift:定制打印输出代替print_第1张图片
Paste_Image.png

参考文章:
http://www.jianshu.com/p/69cfa999b4a3

你可能感兴趣的:(swift:定制打印输出代替print)