Created
April 23, 2016 07:00
-
-
Save rakkang/5dcf45efd8f341c3fef1c4ae93724ad9 to your computer and use it in GitHub Desktop.
Control your log with DEBUG or RELEASE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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