Skip to content

Instantly share code, notes, and snippets.

@RunesReader
Created January 23, 2021 17:58
Show Gist options
  • Save RunesReader/24534950c6cde683674fb0dca5a1751a to your computer and use it in GitHub Desktop.
Save RunesReader/24534950c6cde683674fb0dca5a1751a to your computer and use it in GitHub Desktop.
Debug Log
import Foundation
struct Debug {
static func nslogDebug(_ message: String, function: String = #function, file: String = #file) {
if let range = file.range(of: "([A-z])*.swift", options: String.CompareOptions.regularExpression) {
let fileName = file[range.lowerBound..<range.upperBound]
logDebug(message: "****: \(fileName) \(function) - \(message)")
}
else {
logDebug(message: "****: \(function) - \(message)")
}
}
static func logDebug(message: String, function: String = #function) {
#if DEBUG
print("DEBUG: \(function) - \(message)")
#elseif STAGING
print("DEBUG: \(function) - \(message)")
#endif
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment