Swift 简单的Debug输出替代Print

struct Log {
    
    static func debug(_ message: T, file: String = #file, function: String = #function, line: Int = #line) {
        #if DEBUG
            //获取文件名
            let fileName = (file as NSString).lastPathComponent
            //打印日志内容
            print("Debug: \(fileName):\(line) \(function) | \(message)")
        #endif
    }
}

你可能感兴趣的:(Swift 简单的Debug输出替代Print)