2023-06-14 16:16:56 +02:00
|
|
|
import SwiftUI
|
|
|
|
|
2023-06-14 17:52:43 +02:00
|
|
|
private let df: DateFormatter = {
|
|
|
|
let df = DateFormatter()
|
|
|
|
df.dateStyle = .short
|
|
|
|
df.timeStyle = .medium
|
|
|
|
return df
|
|
|
|
}()
|
|
|
|
|
2023-06-14 16:16:56 +02:00
|
|
|
struct LogView: View {
|
|
|
|
|
|
|
|
@EnvironmentObject
|
|
|
|
var log: Log
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
List(log.logEntries) { entry in
|
|
|
|
VStack(alignment: .leading) {
|
|
|
|
HStack {
|
|
|
|
Text(entry.level.description)
|
|
|
|
Spacer()
|
|
|
|
Text(df.string(from: entry.date))
|
|
|
|
}.font(.footnote)
|
|
|
|
Text(entry.message)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct LogView_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
LogView()
|
|
|
|
.environmentObject(Log())
|
|
|
|
}
|
|
|
|
}
|