PacketTunnelProvider: Show log timestamp

This commit is contained in:
Jason A. Donenfeld 2018-12-07 23:56:26 +01:00
parent 99f0e457c3
commit 9992322186
1 changed files with 3 additions and 14 deletions

View File

@ -202,7 +202,9 @@ private func wg_log(_ type: OSLogType, message msg: String) {
} }
private func file_log(type: OSLogType, message: String) { private func file_log(type: OSLogType, message: String) {
var msgLine = type.toMessagePrefix() + message let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS: "
var msgLine = formatter.string(from: Date()) + message
if (msgLine.last! != "\n") { if (msgLine.last! != "\n") {
msgLine.append("\n") msgLine.append("\n")
} }
@ -212,16 +214,3 @@ private func file_log(type: OSLogType, message: String) {
logFileHandle.synchronizeFile() logFileHandle.synchronizeFile()
} }
} }
extension OSLogType {
func toMessagePrefix() -> String {
switch (self) {
case .debug: return "Debug: "
case .info: return "Info: "
case .error: return "Error: "
case .fault: return "Fault: "
default:
return "Unknown: "
}
}
}