Skip to content

Instantly share code, notes, and snippets.

@hishma
Created December 17, 2015 00:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hishma/e61b0f0ea1b47c1428b0 to your computer and use it in GitHub Desktop.
Save hishma/e61b0f0ea1b47c1428b0 to your computer and use it in GitHub Desktop.
Debug like a caveman in swift
func logPretty(message: String? = nil, file: String = __FILE__, line: UInt = __LINE__, function: StaticString = __FUNCTION__) {
var pretty = "\((file as NSString).lastPathComponent)(\(line)) : \(function)"
if let message = message where !message.isEmpty {
pretty += " ☞ \(message)"
}
print(pretty)
}
func dlogPretty(message: String? = nil, file: String = __FILE__, line: UInt = __LINE__, function: StaticString = __FUNCTION__) {
#if DEBUG
logPretty(message, file: file, line: line, function: function)
#endif
}
@erolando
Copy link

great

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment