Skip to content

Instantly share code, notes, and snippets.

@ochim
Last active November 13, 2020 10:30
Show Gist options
  • Save ochim/d0e524e26ffeecf68170b98a1789fea7 to your computer and use it in GitHub Desktop.
Save ochim/d0e524e26ffeecf68170b98a1789fea7 to your computer and use it in GitHub Desktop.
swiftのprint()をカスタマイズ
func print(_ items: Any..., separator: String = " ", terminator: String = "\n") {
#if DEBUG
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
// 文頭に日時を付与する
Swift.print(formatter.string(from: Date()), terminator: " ")
Swift.print(items, separator: separator, terminator: terminator)
#else
// なにもしない
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment