Skip to content

Instantly share code, notes, and snippets.

@rakkang
Created April 23, 2016 07:00
Show Gist options
  • Save rakkang/5dcf45efd8f341c3fef1c4ae93724ad9 to your computer and use it in GitHub Desktop.
Save rakkang/5dcf45efd8f341c3fef1c4ae93724ad9 to your computer and use it in GitHub Desktop.
Control your log with DEBUG or RELEASE
// Refer: http://swifter.tips/condition-compile/
// 使用之前需要在项目的 Build Settings 中,找到 Swift Compiler - Custom Flags,并在其中的 Other Swift Flags 加上 -D DEBUG
class Utils {
/**
Control your log an DEBUG and RELEASE
- parameter anyObj: any info
- parameter file: Logging file name
- parameter fun: Logging function name
- parameter line: Logging line
*/
static func Log(anyObj: AnyObject, file: String = #file, fun: String = #function, line: Int = #line) {
#if DEBUG
let paths = file.componentsSeparatedByString("/")
let funcs = fun.componentsSeparatedByString("(")
NSLog("\(paths.last!)#\(funcs.first!)(:\(line))> \(anyObj)")
#endif
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment