mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2025-06-29 04:39:53 +00:00
ios: set log level
This commit is contained in:
parent
0e9cc8b3a8
commit
c3671b04c5
4 changed files with 42 additions and 0 deletions
|
@ -1286,6 +1286,10 @@ func apiGetVersion() throws -> CoreVersionInfo {
|
||||||
throw r
|
throw r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func apiSetAppLogLevel(_ ll: ChatLogLevel) async throws {
|
||||||
|
try await sendCommandOkResp(.setAppLogLevel(appLogLevel: ll))
|
||||||
|
}
|
||||||
|
|
||||||
private func currentUserId(_ funcName: String) throws -> Int64 {
|
private func currentUserId(_ funcName: String) throws -> Int64 {
|
||||||
if let userId = ChatModel.shared.currentUser?.userId {
|
if let userId = ChatModel.shared.currentUser?.userId {
|
||||||
return userId
|
return userId
|
||||||
|
|
|
@ -12,6 +12,7 @@ import SimpleXChat
|
||||||
struct DeveloperView: View {
|
struct DeveloperView: View {
|
||||||
@AppStorage(DEFAULT_DEVELOPER_TOOLS) private var developerTools = false
|
@AppStorage(DEFAULT_DEVELOPER_TOOLS) private var developerTools = false
|
||||||
@AppStorage(GROUP_DEFAULT_CONFIRM_DB_UPGRADES, store: groupDefaults) private var confirmDatabaseUpgrades = false
|
@AppStorage(GROUP_DEFAULT_CONFIRM_DB_UPGRADES, store: groupDefaults) private var confirmDatabaseUpgrades = false
|
||||||
|
@State private var appLogLevel = appLogLevelGroupDefault.get()
|
||||||
@Environment(\.colorScheme) var colorScheme
|
@Environment(\.colorScheme) var colorScheme
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
|
@ -37,6 +38,24 @@ struct DeveloperView: View {
|
||||||
settingsRow("chevron.left.forwardslash.chevron.right") {
|
settingsRow("chevron.left.forwardslash.chevron.right") {
|
||||||
Toggle("Show developer options", isOn: $developerTools)
|
Toggle("Show developer options", isOn: $developerTools)
|
||||||
}
|
}
|
||||||
|
settingsRow("text.justify") {
|
||||||
|
Picker("Log level", selection: $appLogLevel) {
|
||||||
|
ForEach(ChatLogLevel.allCases, id: \.self) { ll in
|
||||||
|
Text(ll.rawValue)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.frame(height: 36)
|
||||||
|
.onChange(of: appLogLevel) { ll in
|
||||||
|
Task {
|
||||||
|
do {
|
||||||
|
try await apiSetAppLogLevel(ll)
|
||||||
|
appLogLevelGroupDefault.set(ll)
|
||||||
|
} catch let e {
|
||||||
|
logger.error("apiSetAppLogLevel error: \(responseError(e))")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} header: {
|
} header: {
|
||||||
Text("")
|
Text("")
|
||||||
} footer: {
|
} footer: {
|
||||||
|
|
|
@ -140,6 +140,7 @@ public enum ChatCommand {
|
||||||
case apiStandaloneFileInfo(url: String)
|
case apiStandaloneFileInfo(url: String)
|
||||||
// misc
|
// misc
|
||||||
case showVersion
|
case showVersion
|
||||||
|
case setAppLogLevel(appLogLevel: ChatLogLevel)
|
||||||
case string(String)
|
case string(String)
|
||||||
|
|
||||||
public var cmdString: String {
|
public var cmdString: String {
|
||||||
|
@ -297,6 +298,7 @@ public enum ChatCommand {
|
||||||
case let .apiDownloadStandaloneFile(userId, link, file): return "/_download \(userId) \(link) \(file.filePath)"
|
case let .apiDownloadStandaloneFile(userId, link, file): return "/_download \(userId) \(link) \(file.filePath)"
|
||||||
case let .apiStandaloneFileInfo(link): return "/_download info \(link)"
|
case let .apiStandaloneFileInfo(link): return "/_download info \(link)"
|
||||||
case .showVersion: return "/version"
|
case .showVersion: return "/version"
|
||||||
|
case let .setAppLogLevel(ll): return "/log \(ll.rawValue)"
|
||||||
case let .string(str): return str
|
case let .string(str): return str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -429,6 +431,7 @@ public enum ChatCommand {
|
||||||
case .apiDownloadStandaloneFile: return "apiDownloadStandaloneFile"
|
case .apiDownloadStandaloneFile: return "apiDownloadStandaloneFile"
|
||||||
case .apiStandaloneFileInfo: return "apiStandaloneFileInfo"
|
case .apiStandaloneFileInfo: return "apiStandaloneFileInfo"
|
||||||
case .showVersion: return "showVersion"
|
case .showVersion: return "showVersion"
|
||||||
|
case .setAppLogLevel: return "setAppLogLevel"
|
||||||
case .string: return "console command"
|
case .string: return "console command"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2167,3 +2170,11 @@ public enum UserNetworkType: String, Codable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ChatLogLevel: String, Codable, CaseIterable {
|
||||||
|
case debug
|
||||||
|
case info
|
||||||
|
case warn
|
||||||
|
case error
|
||||||
|
case important
|
||||||
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ public let GROUP_DEFAULT_INITIAL_RANDOM_DB_PASSPHRASE = "initialRandomDBPassphra
|
||||||
public let GROUP_DEFAULT_CONFIRM_DB_UPGRADES = "confirmDBUpgrades"
|
public let GROUP_DEFAULT_CONFIRM_DB_UPGRADES = "confirmDBUpgrades"
|
||||||
public let GROUP_DEFAULT_CALL_KIT_ENABLED = "callKitEnabled"
|
public let GROUP_DEFAULT_CALL_KIT_ENABLED = "callKitEnabled"
|
||||||
public let GROUP_DEFAULT_PQ_EXPERIMENTAL_ENABLED = "pqExperimentalEnabled" // no longer used
|
public let GROUP_DEFAULT_PQ_EXPERIMENTAL_ENABLED = "pqExperimentalEnabled" // no longer used
|
||||||
|
public let GROUP_DEFAULT_APP_LOG_LEVEL = "appLogLevel"
|
||||||
|
|
||||||
public let APP_GROUP_NAME = "group.chat.simplex.app"
|
public let APP_GROUP_NAME = "group.chat.simplex.app"
|
||||||
|
|
||||||
|
@ -76,6 +77,7 @@ public func registerGroupDefaults() {
|
||||||
GROUP_DEFAULT_CONFIRM_DB_UPGRADES: false,
|
GROUP_DEFAULT_CONFIRM_DB_UPGRADES: false,
|
||||||
GROUP_DEFAULT_CALL_KIT_ENABLED: true,
|
GROUP_DEFAULT_CALL_KIT_ENABLED: true,
|
||||||
GROUP_DEFAULT_PQ_EXPERIMENTAL_ENABLED: false,
|
GROUP_DEFAULT_PQ_EXPERIMENTAL_ENABLED: false,
|
||||||
|
GROUP_DEFAULT_APP_LOG_LEVEL: ChatLogLevel.important.rawValue,
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +217,12 @@ public let confirmDBUpgradesGroupDefault = BoolDefault(defaults: groupDefaults,
|
||||||
|
|
||||||
public let callKitEnabledGroupDefault = BoolDefault(defaults: groupDefaults, forKey: GROUP_DEFAULT_CALL_KIT_ENABLED)
|
public let callKitEnabledGroupDefault = BoolDefault(defaults: groupDefaults, forKey: GROUP_DEFAULT_CALL_KIT_ENABLED)
|
||||||
|
|
||||||
|
public let appLogLevelGroupDefault = EnumDefault<ChatLogLevel>(
|
||||||
|
defaults: groupDefaults,
|
||||||
|
forKey: GROUP_DEFAULT_APP_LOG_LEVEL,
|
||||||
|
withDefault: .important
|
||||||
|
)
|
||||||
|
|
||||||
public class DateDefault {
|
public class DateDefault {
|
||||||
var defaults: UserDefaults
|
var defaults: UserDefaults
|
||||||
var key: String
|
var key: String
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue