Skip to content

Commit 4648b02

Browse files
committed
let's just use simple formatted Date.now
1 parent 95db0c7 commit 4648b02

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

Samples/Sources/SampleDiningPhilosophers/SamplePrettyLogHandler.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import Distributed
1616
import Logging
17+
import struct Foundation.Date
1718

1819
@testable import DistributedCluster
1920

@@ -129,18 +130,7 @@ struct SamplePrettyLogHandler: LogHandler {
129130
}
130131

131132
private func timestamp() -> String {
132-
var buffer = [Int8](repeating: 0, count: 255)
133-
var timestamp = time(nil)
134-
guard let localTime = localtime(&timestamp) else { return "" } // FIXME: Handle safely
135-
// This format is pleasant to read in local sample apps:
136-
strftime(&buffer, buffer.count, "%H:%M:%S", localTime)
137-
// The usual full format is:
138-
// strftime(&buffer, buffer.count, "%Y-%m-%dT%H:%M:%S%z", localTime)
139-
return buffer.withUnsafeBufferPointer {
140-
$0.withMemoryRebound(to: CChar.self) {
141-
String(cString: $0.baseAddress!)
142-
}
143-
}
133+
Date.now.formatted(date: .omitted, time: .standard)
144134
}
145135
}
146136

0 commit comments

Comments
 (0)