Skip to content

Instantly share code, notes, and snippets.

@clmntcrl
Last active August 29, 2015 14:11
Show Gist options
  • Save clmntcrl/13ca14b34feef49cd8d0 to your computer and use it in GitHub Desktop.
Save clmntcrl/13ca14b34feef49cd8d0 to your computer and use it in GitHub Desktop.
Building Echo customizable log format #2. Full post: http://clmntcrl.io/blog/building-echo-customizable-log-format/.
enum EchoComponent {
case DateTime
case Flag
case Filename
case Function
case Line
case Message
}
extension EchoComponent: Printable {
public var description: String {
switch self {
case .DateTime:
return "[datetime]"
case .Flag:
return "[flag]"
case .Filename:
return "[filename]"
case .Function:
return "[function]"
case .Line:
return "[line]"
case .Message:
return "[message]"
}
}
}
struct Echo {
var format = "\(EchoComponent.Flag) [\(EchoComponent.DateTime)] " +
"[\(EchoComponent.Filename):\(EchoComponent.Line)] \(EchoComponent.Message)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment