Skip to content

Instantly share code, notes, and snippets.

@bishalg
Created September 21, 2015 06:09
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 bishalg/319e68633c74a71860da to your computer and use it in GitHub Desktop.
Save bishalg/319e68633c74a71860da to your computer and use it in GitHub Desktop.
Debug only Logger for Swift using NSLog
import Foundation
#if DEBUG
func dLog(@autoclosure message: () -> String, filename: NSString = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) {
NSLog("[\(filename.lastPathComponent):\(line)] \(function) - %@", message())
}
#else
func dLog(@autoclosure message: () -> String, filename: NSString = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) {
}
#endif
func aLog(message: String, filename: NSString = __FILE__, function: String = __FUNCTION__, line: Int = __LINE__) {
NSLog("[\(filename.lastPathComponent):\(line)] \(function) - %@", message)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment