Add developer options for Rust's Trace Log Packs. (#3929)
* Add support for configuring log packs. * Update call widget parameters. * Update the SDK.
This commit is contained in:
@@ -550,6 +550,7 @@
|
||||
6DC8E43BA04AC2AC4EB2EB97 /* AnalyticsPromptScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18486B87745B1811E7FBD3D2 /* AnalyticsPromptScreenModels.swift */; };
|
||||
6E03A710799E6C65C0AB36BC /* TargetConfiguration.swift in Sources */ = {isa = PBXBuildFile; fileRef = B5D829FD8958376614504B18 /* TargetConfiguration.swift */; };
|
||||
6E391F7F628D984AF44385D9 /* RoomAttachmentPicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 128501375217576AF0FE3E92 /* RoomAttachmentPicker.swift */; };
|
||||
6E44638FDF7D4B0F80EFA7EA /* TraceLogPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7149BDDE47F8AD104E644E2 /* TraceLogPack.swift */; };
|
||||
6E47D126DD7585E8F8237CE7 /* LoadableAvatarImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = B590BD4507D4F0A377FDE01A /* LoadableAvatarImage.swift */; };
|
||||
6E4E401BE97AC241DA7C7716 /* AppLockSetupSettingsScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 502F986D57158674172C58E3 /* AppLockSetupSettingsScreenModels.swift */; };
|
||||
6E63704717F17593A475D152 /* RoomNotificationSettingsScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = DA14564EE143F73F7E4D1F79 /* RoomNotificationSettingsScreenModels.swift */; };
|
||||
@@ -848,6 +849,7 @@
|
||||
A5B455D1A6DADF7476F7B417 /* EmojiProviderProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8BCCE3D12B0A9C6E559B5B5A /* EmojiProviderProtocol.swift */; };
|
||||
A5B9EF45C7B8ACEB4954AE36 /* LoginScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9780389F8A53E4D26E23DD03 /* LoginScreenViewModelProtocol.swift */; };
|
||||
A5D551E5691749066E0E0C44 /* RoomDetailsScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 837B440C4705E4B899BCB899 /* RoomDetailsScreenViewModel.swift */; };
|
||||
A5FD8284744E2FECFC842FC1 /* TraceLogPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7149BDDE47F8AD104E644E2 /* TraceLogPack.swift */; };
|
||||
A64B52D9F73F9A6B95AF24FE /* UserDetailsEditScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4CD503F5E0938FE53C7C6E7 /* UserDetailsEditScreenCoordinator.swift */; };
|
||||
A6B83EB78F025D21B6EBA90C /* CompoundIcon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 044E501B8331B339874D1B96 /* CompoundIcon.swift */; };
|
||||
A6D4C5EEA85A6A0ABA1559D6 /* RoomDetailsEditScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 16D09C79746BDCD9173EB3A7 /* RoomDetailsEditScreenModels.swift */; };
|
||||
@@ -875,6 +877,7 @@
|
||||
AAF0BBED840DF4A53EE85E77 /* MatrixRustSDK in Frameworks */ = {isa = PBXBuildFile; productRef = C2C69B8BA5A9702E7A8BC08F /* MatrixRustSDK */; };
|
||||
ABD29E06DD1224812E750AF8 /* ReadReceiptCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D75941CBD7D336F831924EC /* ReadReceiptCell.swift */; };
|
||||
AC1DB27A4134470846BE49F6 /* UserProfileScreenViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0BD116096CAA9139B95EEA9C /* UserProfileScreenViewModel.swift */; };
|
||||
AC3C3D6D4AD31F13EE987390 /* TraceLogPack.swift in Sources */ = {isa = PBXBuildFile; fileRef = D7149BDDE47F8AD104E644E2 /* TraceLogPack.swift */; };
|
||||
AC69B6DF15FC451AB2945036 /* UserSessionStoreProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = BEBA759D1347CFFB3D84ED1F /* UserSessionStoreProtocol.swift */; };
|
||||
AC7AA215D60FBC307F984028 /* Consumable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 127A57D053CE8C87B5EFB089 /* Consumable.swift */; };
|
||||
AC90434798E7894370E80E66 /* SecureBackupScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = D79BB714D28C9F588DD69353 /* SecureBackupScreenViewModelProtocol.swift */; };
|
||||
@@ -2381,6 +2384,7 @@
|
||||
D653265D006E708E4E51AD64 /* HomeScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeScreenCoordinator.swift; sourceTree = "<group>"; };
|
||||
D66B5D86A9AB95E0E01BED82 /* uk */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = uk; path = uk.lproj/InfoPlist.strings; sourceTree = "<group>"; };
|
||||
D6DC38E64A5ED3FDB201029A /* BugReportService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BugReportService.swift; sourceTree = "<group>"; };
|
||||
D7149BDDE47F8AD104E644E2 /* TraceLogPack.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TraceLogPack.swift; sourceTree = "<group>"; };
|
||||
D7673F2B0B038FAB2A8D16AD /* ElementTextFieldStyle.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ElementTextFieldStyle.swift; sourceTree = "<group>"; };
|
||||
D77B3D4950F1707E66E4A45A /* AnalyticsConfiguration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalyticsConfiguration.swift; sourceTree = "<group>"; };
|
||||
D77F75B3E9F99864048A422A /* DeactivateAccountScreenViewModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeactivateAccountScreenViewModelTests.swift; sourceTree = "<group>"; };
|
||||
@@ -2744,6 +2748,7 @@
|
||||
41A8571A8A071FB41778C016 /* ExtensionLogger.swift */,
|
||||
2711E5996016ABD6EAAEB58A /* LogLevel.swift */,
|
||||
111B698739E3410E2CDB7144 /* MXLog.swift */,
|
||||
D7149BDDE47F8AD104E644E2 /* TraceLogPack.swift */,
|
||||
83B574805B9812C111D6215D /* Tracing.swift */,
|
||||
);
|
||||
path = Logging;
|
||||
@@ -6647,6 +6652,7 @@
|
||||
88A3FBBC3D67996863DB9CAF /* TargetConfiguration.swift in Sources */,
|
||||
719E7AAD1F8E68F68F30FECD /* Task.swift in Sources */,
|
||||
E0FB26262689F04D66A949D7 /* TestablePreview.swift in Sources */,
|
||||
AC3C3D6D4AD31F13EE987390 /* TraceLogPack.swift in Sources */,
|
||||
B81840E45D8746A4692DA774 /* Tracing.swift in Sources */,
|
||||
DDB47D29C6865669288BF87C /* UIFont+AttributedStringBuilder.m in Sources */,
|
||||
45D6DC594816288983627484 /* UITestsScreenIdentifier.swift in Sources */,
|
||||
@@ -6818,6 +6824,7 @@
|
||||
5AA81A4E2D40A32A9E7F71F2 /* ShareExtensionView.swift in Sources */,
|
||||
5AC5CD6D893073EE4D9A277E /* ShareExtensionViewController.swift in Sources */,
|
||||
6E03A710799E6C65C0AB36BC /* TargetConfiguration.swift in Sources */,
|
||||
A5FD8284744E2FECFC842FC1 /* TraceLogPack.swift in Sources */,
|
||||
89DF67AECBF9D0EE0DDB7737 /* Tracing.swift in Sources */,
|
||||
03BD83E8BDD23AE059802E0D /* UITestsScreenIdentifier.swift in Sources */,
|
||||
26252AA9AED64010788F4C26 /* UIView.swift in Sources */,
|
||||
@@ -7639,6 +7646,7 @@
|
||||
67EFF46180B939CBF389AECD /* TimelineView.swift in Sources */,
|
||||
98EE4259A4A49BC757BA442C /* TimelineViewModel.swift in Sources */,
|
||||
F8B2F5CBCF2A0E0798E8D646 /* TimelineViewModelProtocol.swift in Sources */,
|
||||
6E44638FDF7D4B0F80EFA7EA /* TraceLogPack.swift in Sources */,
|
||||
126CBCF5B0145FA1377C1316 /* Tracing.swift in Sources */,
|
||||
298F9EC30E918F12AB7F1EE8 /* TypingIndicatorView.swift in Sources */,
|
||||
36AC963F2F04069B7FF1AA0C /* UIConstants.swift in Sources */,
|
||||
@@ -8557,7 +8565,7 @@
|
||||
repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift";
|
||||
requirement = {
|
||||
kind = exactVersion;
|
||||
version = 25.03.20;
|
||||
version = 25.03.21;
|
||||
};
|
||||
};
|
||||
701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = {
|
||||
|
||||
@@ -149,8 +149,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/element-hq/matrix-rust-components-swift",
|
||||
"state" : {
|
||||
"revision" : "d86698c49d66f2cc100a37d55e591f60b98c5bc4",
|
||||
"version" : "25.3.20"
|
||||
"revision" : "93b8303fa004060c8ba6a856e0b66a1d47514490",
|
||||
"version" : "25.3.21"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ class AppCoordinator: AppCoordinatorProtocol, AuthenticationFlowCoordinatorDeleg
|
||||
|
||||
let appSettings = appHooks.appSettingsHook.configure(AppSettings())
|
||||
|
||||
Target.mainApp.configure(logLevel: appSettings.logLevel)
|
||||
Target.mainApp.configure(logLevel: appSettings.logLevel, traceLogPacks: appSettings.traceLogPacks)
|
||||
|
||||
let appName = InfoPlistReader.main.bundleDisplayName
|
||||
let appVersion = InfoPlistReader.main.bundleShortVersionString
|
||||
|
||||
@@ -11,6 +11,7 @@ import SwiftUI
|
||||
// Common settings between app and NSE
|
||||
protocol CommonSettingsProtocol {
|
||||
var logLevel: LogLevel { get }
|
||||
var traceLogPacks: Set<TraceLogPack> { get }
|
||||
var enableOnlySignedDeviceIsolationMode: Bool { get }
|
||||
var hideInviteAvatars: Bool { get }
|
||||
var hideTimelineMedia: Bool { get }
|
||||
@@ -36,6 +37,7 @@ final class AppSettings {
|
||||
case enableInAppNotifications
|
||||
case pusherProfileTag
|
||||
case logLevel
|
||||
case traceLogPacks
|
||||
case viewSourceEnabled
|
||||
case optimizeMediaUploads
|
||||
case appAppearance
|
||||
@@ -306,6 +308,9 @@ final class AppSettings {
|
||||
@UserPreference(key: UserDefaultsKeys.logLevel, defaultValue: LogLevel.info, storageType: .userDefaults(store))
|
||||
var logLevel
|
||||
|
||||
@UserPreference(key: UserDefaultsKeys.traceLogPacks, defaultValue: [], storageType: .userDefaults(store))
|
||||
var traceLogPacks: Set<TraceLogPack>
|
||||
|
||||
/// Configuration to enable only signed device isolation mode for crypto. In this mode only devices signed by their owner will be considered in e2ee rooms.
|
||||
@UserPreference(key: UserDefaultsKeys.enableOnlySignedDeviceIsolationMode, defaultValue: false, storageType: .userDefaults(store))
|
||||
var enableOnlySignedDeviceIsolationMode
|
||||
|
||||
@@ -15,23 +15,35 @@ enum Target: String {
|
||||
|
||||
private static var isConfigured = false
|
||||
|
||||
func configure(logLevel: LogLevel) {
|
||||
func configure(logLevel: LogLevel, traceLogPacks: Set<TraceLogPack>) {
|
||||
guard !Self.isConfigured else {
|
||||
return
|
||||
}
|
||||
|
||||
switch self {
|
||||
case .mainApp:
|
||||
let tracingConfiguration = Tracing.buildConfiguration(logLevel: logLevel, currentTarget: rawValue, filePrefix: nil)
|
||||
let tracingConfiguration = Tracing.buildConfiguration(logLevel: logLevel,
|
||||
traceLogPacks: traceLogPacks,
|
||||
currentTarget: rawValue,
|
||||
filePrefix: nil)
|
||||
initPlatform(config: tracingConfiguration, useLightweightTokioRuntime: false)
|
||||
case .nse:
|
||||
let tracingConfiguration = Tracing.buildConfiguration(logLevel: logLevel, currentTarget: rawValue, filePrefix: rawValue)
|
||||
let tracingConfiguration = Tracing.buildConfiguration(logLevel: logLevel,
|
||||
traceLogPacks: traceLogPacks,
|
||||
currentTarget: rawValue,
|
||||
filePrefix: rawValue)
|
||||
initPlatform(config: tracingConfiguration, useLightweightTokioRuntime: true)
|
||||
case .shareExtension:
|
||||
let tracingConfiguration = Tracing.buildConfiguration(logLevel: logLevel, currentTarget: rawValue, filePrefix: rawValue)
|
||||
let tracingConfiguration = Tracing.buildConfiguration(logLevel: logLevel,
|
||||
traceLogPacks: traceLogPacks,
|
||||
currentTarget: rawValue,
|
||||
filePrefix: rawValue)
|
||||
initPlatform(config: tracingConfiguration, useLightweightTokioRuntime: true)
|
||||
case .tests:
|
||||
let tracingConfiguration = Tracing.buildConfiguration(logLevel: logLevel, currentTarget: rawValue, filePrefix: rawValue)
|
||||
let tracingConfiguration = Tracing.buildConfiguration(logLevel: logLevel,
|
||||
traceLogPacks: traceLogPacks,
|
||||
currentTarget: rawValue,
|
||||
filePrefix: rawValue)
|
||||
initPlatform(config: tracingConfiguration, useLightweightTokioRuntime: false)
|
||||
}
|
||||
|
||||
|
||||
49
ElementX/Sources/Other/Logging/TraceLogPack.swift
Normal file
49
ElementX/Sources/Other/Logging/TraceLogPack.swift
Normal file
@@ -0,0 +1,49 @@
|
||||
//
|
||||
// Copyright 2025 New Vector Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
||||
// Please see LICENSE files in the repository root for full details.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum TraceLogPack: Codable, CaseIterable {
|
||||
case eventCache, sendQueue, timeline
|
||||
|
||||
var title: String {
|
||||
switch self {
|
||||
case .eventCache:
|
||||
return "Event cache"
|
||||
case .sendQueue:
|
||||
return "Send queue"
|
||||
case .timeline:
|
||||
return "Timeline"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension TraceLogPack {
|
||||
// periphery:ignore - Unused, but added to detect new cases when updating the SDK.
|
||||
init(rustLogPack: MatrixRustSDK.TraceLogPacks) {
|
||||
switch rustLogPack {
|
||||
case .eventCache:
|
||||
self = .eventCache
|
||||
case .sendQueue:
|
||||
self = .sendQueue
|
||||
case .timeline:
|
||||
self = .timeline
|
||||
}
|
||||
}
|
||||
|
||||
var rustLogPack: MatrixRustSDK.TraceLogPacks {
|
||||
switch self {
|
||||
case .eventCache:
|
||||
return .eventCache
|
||||
case .sendQueue:
|
||||
return .sendQueue
|
||||
case .timeline:
|
||||
return .timeline
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ enum Tracing {
|
||||
|
||||
static let fileExtension = "log"
|
||||
|
||||
static func buildConfiguration(logLevel: LogLevel, currentTarget: String, filePrefix: String?) -> TracingConfiguration {
|
||||
static func buildConfiguration(logLevel: LogLevel, traceLogPacks: Set<TraceLogPack>, currentTarget: String, filePrefix: String?) -> TracingConfiguration {
|
||||
let fileName = if let filePrefix {
|
||||
"\(Tracing.filePrefix)-\(filePrefix)"
|
||||
} else {
|
||||
@@ -39,6 +39,7 @@ enum Tracing {
|
||||
let level: LogLevel = ProcessInfo.isRunningIntegrationTests ? .trace : logLevel
|
||||
|
||||
return .init(logLevel: level.rustLogLevel,
|
||||
traceLogPacks: traceLogPacks.map(\.rustLogPack),
|
||||
extraTargets: [currentTarget],
|
||||
writeToStdoutOrSystem: true,
|
||||
writeToFiles: .init(path: logsDirectory.path(percentEncoded: false),
|
||||
|
||||
@@ -37,6 +37,7 @@ enum DeveloperOptionsScreenViewAction {
|
||||
|
||||
protocol DeveloperOptionsProtocol: AnyObject {
|
||||
var logLevel: LogLevel { get set }
|
||||
var traceLogPacks: Set<TraceLogPack> { get set }
|
||||
var publicSearchEnabled: Bool { get set }
|
||||
var hideUnreadMessagesBadge: Bool { get set }
|
||||
var fuzzyRoomListSearchEnabled: Bool { get set }
|
||||
|
||||
@@ -21,6 +21,14 @@ struct DeveloperOptionsScreen: View {
|
||||
Form {
|
||||
Section("Logging") {
|
||||
LogLevelConfigurationView(logLevel: $context.logLevel)
|
||||
|
||||
DisclosureGroup("SDK trace packs") {
|
||||
ForEach(TraceLogPack.allCases, id: \.self) { pack in
|
||||
Toggle(isOn: $context.traceLogPacks[pack]) {
|
||||
Text(pack.title)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Section("General") {
|
||||
@@ -153,6 +161,20 @@ private struct LogLevelConfigurationView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private extension Set<TraceLogPack> {
|
||||
/// A custom subscript that allows binding a toggle to add/remove a pack from the array.
|
||||
subscript(pack: TraceLogPack) -> Bool {
|
||||
get { contains(pack) }
|
||||
set {
|
||||
if newValue {
|
||||
insert(pack)
|
||||
} else {
|
||||
remove(pack)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
struct DeveloperOptionsScreen_Previews: PreviewProvider {
|
||||
|
||||
@@ -81,11 +81,17 @@ class ElementCallWidgetDriver: WidgetCapabilitiesProvider, ElementCallWidgetDriv
|
||||
preload: nil,
|
||||
fontScale: nil,
|
||||
appPrompt: false,
|
||||
skipLobby: true,
|
||||
confineToRoom: true,
|
||||
font: nil,
|
||||
analyticsId: nil,
|
||||
encryption: useEncryption ? .perParticipantKeys : .unencrypted))
|
||||
encryption: useEncryption ? .perParticipantKeys : .unencrypted,
|
||||
intent: .startCall,
|
||||
hideScreensharing: false, // The web view will hide it automatically
|
||||
posthogUserId: nil,
|
||||
posthogApiHost: nil,
|
||||
posthogApiKey: nil,
|
||||
rageshakeSubmitUrl: nil,
|
||||
sentryDsn: nil,
|
||||
sentryEnvironment: nil))
|
||||
} catch {
|
||||
MXLog.error("Failed to build widget settings: \(error)")
|
||||
return .failure(.failedBuildingWidgetSettings)
|
||||
|
||||
@@ -79,7 +79,7 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
|
||||
return contentHandler(request.content)
|
||||
}
|
||||
|
||||
Target.nse.configure(logLevel: settings.logLevel)
|
||||
Target.nse.configure(logLevel: settings.logLevel, traceLogPacks: settings.traceLogPacks)
|
||||
|
||||
handler = contentHandler
|
||||
modifiedContent = request.content.mutableCopy() as? UNMutableNotificationContent
|
||||
|
||||
@@ -15,7 +15,7 @@ class ShareExtensionViewController: UIViewController {
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
Target.shareExtension.configure(logLevel: appSettings.logLevel)
|
||||
Target.shareExtension.configure(logLevel: appSettings.logLevel, traceLogPacks: appSettings.traceLogPacks)
|
||||
|
||||
addChild(hostingController)
|
||||
view.addMatchedSubview(hostingController.view)
|
||||
|
||||
@@ -22,7 +22,7 @@ class LoggingTests: XCTestCase {
|
||||
let target = "tests"
|
||||
XCTAssertTrue(Tracing.logFiles.isEmpty)
|
||||
|
||||
Target.tests.configure(logLevel: .info)
|
||||
Target.tests.configure(logLevel: .info, traceLogPacks: [])
|
||||
|
||||
// There is something weird with Rust logging where the file writing handle doesn't
|
||||
// notice that the file it is writing to was deleted, so we can't run these checks
|
||||
@@ -179,7 +179,7 @@ class LoggingTests: XCTestCase {
|
||||
contentType: nil))
|
||||
|
||||
// When logging that value
|
||||
Target.tests.configure(logLevel: .info)
|
||||
Target.tests.configure(logLevel: .info, traceLogPacks: [])
|
||||
|
||||
MXLog.info(textMessage)
|
||||
MXLog.info(noticeMessage)
|
||||
|
||||
@@ -59,7 +59,7 @@ packages:
|
||||
# Element/Matrix dependencies
|
||||
MatrixRustSDK:
|
||||
url: https://github.com/element-hq/matrix-rust-components-swift
|
||||
exactVersion: 25.03.20
|
||||
exactVersion: 25.03.21
|
||||
# path: ../matrix-rust-sdk
|
||||
Compound:
|
||||
url: https://github.com/element-hq/compound-ios
|
||||
|
||||
Reference in New Issue
Block a user