Swift 配置Print

2016-07-22  本文已影响51人  Theshy

一 OC中配置NSLog输出

//////debug日志输出
#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...) {}
#endif

二 swift中配置Print输出

如图配置

然后在AppDelegate.swift中加入方法

func Log<T>(_ message: T, file: String = #file, funcName: String = #function, lineNum: Int = #line) {
    #if DEBUG
        let fileName: String = (file as NSString).lastPathComponent
        print("***********Log************\n🐶🐶【\(fileName):\(lineNum)】->>   \(message)")
    #endif
}

然后可以切换 DebugRelease 查看输出信息啦~

上一篇下一篇

猜你喜欢

热点阅读