mirror of
https://github.com/cranci1/Sora.git
synced 2026-05-06 18:19:35 +00:00
done captian!
This commit is contained in:
parent
db2eae3819
commit
2655d57269
4 changed files with 9 additions and 12 deletions
|
|
@ -18,7 +18,7 @@ class Logger {
|
|||
|
||||
private var logs: [LogEntry] = []
|
||||
private let logFileURL: URL
|
||||
private let logFilterViewModel = LogFilterViewModel.shared // Use shared instance
|
||||
private let logFilterViewModel = LogFilterViewModel.shared
|
||||
|
||||
private init() {
|
||||
let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
|
||||
|
|
@ -26,7 +26,6 @@ class Logger {
|
|||
}
|
||||
|
||||
func log(_ message: String, type: String = "General") {
|
||||
// Check if the log type is enabled
|
||||
guard logFilterViewModel.isFilterEnabled(for: type) else { return }
|
||||
|
||||
let entry = LogEntry(message: message, type: type, timestamp: Date())
|
||||
|
|
@ -38,7 +37,7 @@ class Logger {
|
|||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateFormat = "dd-MM-yyyy HH:mm:ss"
|
||||
return logs.map { "[\(dateFormatter.string(from: $0.timestamp))] [\($0.type)] \($0.message)" }
|
||||
.joined(separator: "\n----------------------------------------------------------\n")
|
||||
.joined(separator: "\n----\n")
|
||||
}
|
||||
|
||||
func clearLogs() {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import SwiftUI
|
|||
|
||||
struct SettingsViewLogger: View {
|
||||
@State private var logs: String = ""
|
||||
@StateObject private var filterViewModel = LogFilterViewModel.shared // Use shared instance
|
||||
@StateObject private var filterViewModel = LogFilterViewModel.shared
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ class LogFilterViewModel: ObservableObject {
|
|||
|
||||
private let userDefaultsKey = "LogFilterStates"
|
||||
private let hardcodedFilters: [(type: String, description: String, defaultState: Bool)] = [
|
||||
("General", "Logs for general events and activities.", true), // Turned on by default
|
||||
("Stream", "Logs for streaming and video playback.", true), // Turned on by default
|
||||
("Error", "Logs for errors and critical issues.", true), // Turned on by default
|
||||
("Debug", "Logs for debugging and troubleshooting.", false) // Turned off by default
|
||||
("General", "Logs for general events and activities.", true),
|
||||
("Stream", "Logs for streaming and video playback.", true),
|
||||
("Error", "Logs for errors and critical issues.", true),
|
||||
("Debug", "Logs for debugging and troubleshooting.", false)
|
||||
]
|
||||
|
||||
private init() {
|
||||
|
|
@ -41,7 +41,7 @@ class LogFilterViewModel: ObservableObject {
|
|||
filters = hardcodedFilters.map {
|
||||
LogFilter(
|
||||
type: $0.type,
|
||||
isEnabled: savedStates[$0.type] ?? $0.defaultState, // Use saved state if available, otherwise default
|
||||
isEnabled: savedStates[$0.type] ?? $0.defaultState,
|
||||
description: $0.description
|
||||
)
|
||||
}
|
||||
|
|
@ -84,7 +84,7 @@ struct SettingsViewLoggerFilter: View {
|
|||
Text(filter.description)
|
||||
.font(.subheadline)
|
||||
.foregroundColor(.secondary)
|
||||
.padding(.leading, 5) // Indent description slightly
|
||||
.padding(.leading, 5)
|
||||
}
|
||||
.padding(.vertical, 5)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,14 +28,12 @@ struct SettingsView: View {
|
|||
|
||||
Section(header: Text("External Features")) {
|
||||
NavigationLink(destination: SettingsViewModule()) {
|
||||
Image(systemName: "puzzlepiece.fill")
|
||||
Text("Modules")
|
||||
}
|
||||
}
|
||||
|
||||
Section(header: Text("Debug")) {
|
||||
NavigationLink(destination: SettingsViewLogger()) {
|
||||
Image(systemName: "doc.text.fill")
|
||||
Text("Logs")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue