swift:定制打印输出代替print

2016-09-22  本文已影响83人  半江瑟瑟
想要的打印效果 **<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
}
Paste_Image.png

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

上一篇下一篇

猜你喜欢

热点阅读