swift3.0 自定义Log

来源:互联网 发布:咫尺网络登录 编辑:程序博客网 时间:2024/06/08 14:02

swift3.0 自定义Log




1.开发模式下打印Log,发布模式下不打印Log配置(如图)




2.代码实现(文件名 -- 函数名 -- 行数 -- 自定义Log)

public func LTLog<T>(funcName: String = #function,_ message: T,file: String = #file, line: Int = #line) {    #if LTDEBUG    let files = (file as NSString).lastPathComponent.replacingOccurrences(of: ".swift", with: "")    print("\(files) --> \(funcName) -->  \(line) --> \(message) ")    #endif}

3.调用