mirror of
https://github.com/apple/swift-log
synced 2026-11-26 04:07:49 +00:00
Logging: avoid a deprecation warning on Windows (#199)
Windows recommends the safety extension usage which in this case explicitly allow you to be informed of failures. This just avoids an annoying warning when using logging in projects.
This commit is contained in:
1 parent
7ebe44cb03
commit
02770d91fc
1 file changed
+10
@@ -1132,9 +1132,19 @@ public struct StreamLogHandler: LogHandler {
|
||||
|
||||
private func timestamp() -> String {
|
||||
var buffer = [Int8](repeating: 0, count: 255)
|
||||
#if os(Windows)
|
||||
var timestamp: __time64_t = __time64_t()
|
||||
_ = _time64(×tamp)
|
||||
|
||||
var localTime: tm = tm()
|
||||
_ = _localtime64_s(&localTime, ×tamp)
|
||||
|
||||
_ = strftime(&buffer, buffer.count, "%Y-%m-%dT%H:%M:%S%z", &localTime)
|
||||
#else
|
||||
var timestamp = time(nil)
|
||||
let localTime = localtime(×tamp)
|
||||
strftime(&buffer, buffer.count, "%Y-%m-%dT%H:%M:%S%z", localTime)
|
||||
#endif
|
||||
return buffer.withUnsafeBufferPointer {
|
||||
$0.withMemoryRebound(to: CChar.self) {
|
||||
String(cString: $0.baseAddress!)
|
||||
|
||||
Reference in new issue
Block a user