Skip to content

Instantly share code, notes, and snippets.

@motokiee
Last active April 14, 2016 02:35
Show Gist options
  • Save motokiee/f625f38d3da21e626149 to your computer and use it in GitHub Desktop.
Save motokiee/f625f38d3da21e626149 to your computer and use it in GitHub Desktop.
Original debug log in Swift
func DebugLog(@autoclosure condition: () -> Bool = true, _ message: String = "", function: StaticString = __FUNCTION__, file: StaticString = __FILE__, line: UInt = __LINE__) {
#if DEBUG
if let fileName = NSURL(string: String(file))?.lastPathComponent {
print("time: \(NSDate()), message: \(message), function: \(function), file: \(fileName), line: \(line)")
} else {
print("time: \(NSDate()), message: \(message), function: \(function), file: \(file), line: \(line)")
}
assert(condition, message, file: file, line: line)
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment