Skip to content

Instantly share code, notes, and snippets.

@berikv
Last active August 29, 2015 14:13
Show Gist options
  • Save berikv/7852e6647b55c4c8445a to your computer and use it in GitHub Desktop.
Save berikv/7852e6647b55c4c8445a to your computer and use it in GitHub Desktop.
Simple logging in swift
func log<T>(message: T, fileName: String = __FILE__, lineNumber: Int = __LINE__, args: CVarArgType...) {
let date = NSDate()
let processInfo = NSProcessInfo()
let appName = processInfo.processName
let combined = String(format: String(stringInterpolationSegment: message), arguments: args)
println("\(date) \(appName) [\(fileName.lastPathComponent):\(lineNumber)] \(combined)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment