Skip to content

Instantly share code, notes, and snippets.

@jlyonsmith
Created November 6, 2015 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlyonsmith/dea70d8f42101f555dbd to your computer and use it in GitHub Desktop.
Save jlyonsmith/dea70d8f42101f555dbd to your computer and use it in GitHub Desktop.
public func Log<T>(item: T, fileName: String = __FILE__, line: Int = __LINE__, funcName:String = __FUNCTION__) {
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MM/dd/yyyy HH:mm:ss:SSS"
let process = NSProcessInfo.processInfo()
let threadId = "?"
var shortFileName = (NSURL(string: fileName)?.lastPathComponent?.componentsSeparatedByString(".").first)
if shortFileName == nil {
shortFileName = "unknown"
}
print("\(dateFormatter.stringFromDate(NSDate())) \(process.processName))[\(process.processIdentifier):\(threadId)] \(shortFileName)(\(line)) \(funcName): \(item)\n")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment