gliyao
12/30/2016 - 9:06 AM

swift_log

swift_log

enum LogTag: String {
	case APP = "[APP]"
	case DEBUG = "[DEBUG]"
	case ERROR = "[ERROR]"
}

fileprivate func debugLog( _ log: @autoclosure () -> Any, _ tags: [LogTag]) {
	#if DEBUG
		var tagStr = ""
		for tag in tags {
			tagStr += tag.rawValue
		}
		
		print( "\(tagStr) \(log())")
	#endif
}

func Log( _ log: @autoclosure () -> Any) {
	debugLog(log, [.APP])
}

func DebugLog( _ log: @autoclosure () -> Any) {
	debugLog(log, [.APP, .DEBUG])
}

func ErrorLog( _ log: @autoclosure () -> Any) {
	debugLog(log, [.APP, .ERROR])
}