Swift - 日志打印
2018-07-27 本文已影响48人
comyn_sheng
/// 日志打印,支持传入不同类型的多个参数
///
/// - Parameters:
/// - message: 内容
/// - file: 文件名
/// - function: 方法名
/// - line: 行号
public func printLog(_ messages: Any..., file: String = #file, function: String = #function, line: Int = #line) {
#if DEBUG
let message = messages.compactMap{ "\($0)" }.joined(separator: " ")
print("\((file as NSString).lastPathComponent)[\(line)] - \(function): \(message)")
#endif
}