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:
Doug
2025-03-21 19:00:13 +00:00
committed by GitHub
parent 8ada12c668
commit a142ce43af
14 changed files with 122 additions and 18 deletions
@@ -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
}
}
}
+2 -1
View File
@@ -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),