Swift 自定义打印, 自定义输出函数 ,自定义log, Debug

func SSLog<T>(_ message: T, file : String = #file, methodName: String = #function, lineNumber : Int = #line) {
    
    #if DEBUG
        ///带后缀 .swift
        // let fileName = (file as NSString).lastPathComponent
        
        ///去掉 .swift
        let filePath = file as NSString
        let filePath_copy = filePath.lastPathComponent as NSString
        let fileName = filePath_copy.deletingPathExtension
        print("\n\(fileName) : \(methodName)__ \(lineNumber) __:\n\(message)")
        
    #endif
}

//工具类写下这个函数之后, 在build settings(ALL) 里面搜索 Other Swift Flags 展开 会看见 Debug 和Release   点击DeBug 后面 +  号  key 不动 输入 value  -D DEBUG   这样只是在Debug 的时候打印调试信息,  release 之后不打印.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值