Guest User

Untitled

a guest
Feb 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. import Foundation
  2.  
  3. public struct Log
  4. {
  5. public static var isEnabled = true
  6.  
  7. public static func debug(_ m: @autoclosure ()->String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) {
  8. print(m(), file ?? "", f, line)
  9. }
  10. public static func error(_ m: @autoclosure ()->String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) {
  11. _print("🚨 \(m())", file, f, line)
  12. }
  13. public static func warn(_ m: @autoclosure ()->String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) {
  14. _print("⚠️ \(m())", file, f, line)
  15. }
  16. private static func _print(_ m: String, _ file: Any? = #file, _ f: String = #function, _ line: UInt = #line) {
  17. if isEnabled {
  18. print("\(file ?? "").\(f):\(line) -\(m)")
  19. }
  20. }
  21. }
  22.  
  23.  
  24. //Use:
  25.  
  26. Log.warn("\(error)")
Add Comment
Please, Sign In to add comment