Skip to content

Instantly share code, notes, and snippets.

@yarshure
Created October 21, 2015 16:04
Show Gist options
  • Save yarshure/fadfac2008459b562edb to your computer and use it in GitHub Desktop.
Save yarshure/fadfac2008459b562edb to your computer and use it in GitHub Desktop.
log style
extension String : CollectionType {}
func myLog<T>(object: T, _ file: String = __FILE__, _ function: String = __FUNCTION__, _ line: Int = __LINE__) {
let fn = file.split { $0 == "/" }.last
if let f = fn {
let info = "\(f).\(function)[\(line)]:\(object)"
NSLog(info)
}
}
@yarshure
Copy link
Author

other version

public func myLog(object: T, _ file: String = FILE, _ function: String = FUNCTION, _ line: Int = LINE) {
//let fn = file.split { $0 == "/" }.last
let fn = file.characters.split { $0 == " " }.map(String.init).last
if let f = fn {
let info = "(f).(function)[(line)]:(object)"
NSLog(info)
}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment