TempTrack-iOS/TempTrack/Storage/LogEntry.swift
2023-06-14 16:16:56 +02:00

34 lines
640 B
Swift

import Foundation
struct LogEntry: Identifiable {
let id: TimeInterval
let date: Date
let level: Log.Level
let message: String
init(date: Date = Date(), level: Log.Level, message: String) {
self.id = date.timeIntervalSince1970
self.date = date
self.level = level
self.message = message
}
}
private let df: DateFormatter = {
let df = DateFormatter()
df.dateStyle = .short
df.timeStyle = .medium
return df
}()
extension LogEntry: CustomStringConvertible {
var description: String {
"[\(df.string(from: date))][\(level.rawValue)] \(message)"
}
}