Skip to content

Commit a8b071b

Browse files
committed
added timestamp to logs
1 parent eb6b31f commit a8b071b

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

SwiftBridge/AltSignLogging.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by Magesh K on 28/06/26.
66
// Copyright © 2026 SideStore. All rights reserved.
77
//
8+
import Foundation
89

910
public enum AltSignLogging {
1011
public private(set) static var isLoggingEnabled = false
@@ -14,14 +15,23 @@ public enum AltSignLogging {
1415
}
1516
}
1617

18+
private func getTag(level: String) -> String {
19+
let formatter = DateFormatter()
20+
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSS'Z'"
21+
formatter.timeZone = TimeZone(secondsFromGMT: 0)
22+
formatter.locale = Locale(identifier: "en_US_POSIX")
23+
let timestamp = formatter.string(from: Date())
24+
return "\(timestamp) \(level): "
25+
}
26+
1727
@inline(__always)
1828
public func debugLog(_ text: @autoclosure () -> String) {
19-
print(text())
29+
print("\(getTag(level: "DEBUG"))\(text())")
2030
}
2131

2232
@inline(__always)
2333
public func verboseLog(_ text: @autoclosure () -> String) {
2434
if AltSignLogging.isLoggingEnabled {
25-
print(text())
35+
print("\(getTag(level: "TRACE"))\(text())")
2636
}
2737
}

0 commit comments

Comments
 (0)