Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Foundation
- public struct Log
- {
- public static var isEnabled = true
- public static func debug(_ m: @autoclosure ()->String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) {
- print(m(), file ?? "", f, line)
- }
- public static func error(_ m: @autoclosure ()->String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) {
- _print("🚨 \(m())", file, f, line)
- }
- public static func warn(_ m: @autoclosure ()->String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) {
- _print("⚠️ \(m())", file, f, line)
- }
- private static func _print(_ m: String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) {
- if isEnabled {
- print("\(file ?? "").\(f):\(line) -\(m)")
- }
- }
- }
- //Use:
- Log.warn("\(error)")
Add Comment
Please, Sign In to add comment