Swift中自定义Log
Swift中自定义Log:依次是类名.方法名.行号.内容.
func LTLog(funcName: String = #function,_ message: T,file: String = #file, line: Int = #line) {
#if DEBUG
let files = (file as NSString).lastPathComponent.replacingOccurrences(of: ".swift", with: "")
print("\(files) --> \(funcName) --> \(line) --> \(message) ")
#endif
}
还要配置以下宏

假如我在一个函数中打印这个"我是靓仔"
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
LTLog("撒大大的")
return true
}
最终会输出
AppDelegate.application(_:didFinishLaunchingWithOptions:)[23]:撒大大的
注:依次是类名.方法名.行号.内容.
网友评论