美文网首页
Swift - 日志打印

Swift - 日志打印

作者: comyn_sheng | 来源:发表于2018-07-27 12:36 被阅读48次
/// 日志打印,支持传入不同类型的多个参数
///
/// - 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
}

相关文章

网友评论

      本文标题:Swift - 日志打印

      本文链接:https://www.haomeiwen.com/subject/tkgwmftx.html