Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. //
  2. // Debug.swift
  3. //
  4. // Created by Craig Hockenberry on 3/15/17.
  5. //
  6. // Usage:
  7. // debugLog("reticulating splines") prints "2019-10-04 11:52:28 SplineReticulationManager: reticulationFunction reticulating splines"
  8. // debugLog() prints "2019-10-04 11:52:28 SplineReticulationManager: reticulationFunction called"
  9. //
  10. // Add "DEBUG" to project or target's "Active Compilation Conditions" for Debug builds.
  11.  
  12. import Foundation
  13.  
  14. func releaseLog(_ message: String = "called", file: String = #file, function: String = #function) {
  15. let timestamp = ISO8601DateFormatter.string(from: Date(), timeZone: TimeZone.current, formatOptions: [.withYear, .withMonth, .withDay, .withDashSeparatorInDate, .withTime, .withColonSeparatorInTime, .withSpaceBetweenDateAndTime])
  16. print("\(timestamp) \(URL(fileURLWithPath: file).deletingPathExtension().lastPathComponent): \(function) \(message)")
  17. }
  18.  
  19. func debugLog(_ message: String = "called", file: String = #file, function: String = #function) {
  20. #if DEBUG
  21. let timestamp = ISO8601DateFormatter.string(from: Date(), timeZone: TimeZone.current, formatOptions: [.withYear, .withMonth, .withDay, .withDashSeparatorInDate, .withTime, .withColonSeparatorInTime, .withSpaceBetweenDateAndTime])
  22. print("\(timestamp) \(URL(fileURLWithPath: file).deletingPathExtension().lastPathComponent): \(function) \(message)")
  23. #endif
  24. }
  25.  
  26. #if true
  27.  
  28. // weed out NSLog usage
  29. @available(iOS, deprecated: 1.0, message: "Convert to debugLog")
  30. public func NSLog(_ format: String, _ args: CVarArg...)
  31. {
  32. }
  33.  
  34. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement