mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
SDK update (#3891)
* Bump the RustSDK to v25.03.11 * Replace oidc login prompt with nil following the changes from https://github.com/matrix-org/matrix-rust-sdk/pull/4761 ``` /// * `prompt` - The desired user experience in the web UI. No value means /// that the user wishes to login into an existing account, and a value of /// `Create` means that the user wishes to register a new account. ``` * Fix trailing closure warnings * Update the client proxy after making `getNotificationSettings()` and `cachedAvatarUrl()` async (they used to be blocking on the rust side). * Move `Room.isEncrypted` to the info publisher and manually update the encryption state when creating the room. * Bump the SDK again to v25.03.12 - This introduces a new way to configure the tokio runtime that we can use to have extensions use less memory - introduce a new Target struct that takes care of setting up rust services (tracing and tokio) for our various targets - cleanup MXLog and friends * Address PR comments * Bump the SDK again, switch back to using `.consent` as the OIDC login prompt (which was reintroduced in matrix-org/matrix-rust-sdk/pull/4791)
This commit is contained in:
@@ -9,8 +9,6 @@ import Foundation
|
||||
import MatrixRustSDK
|
||||
|
||||
enum ExtensionLogger {
|
||||
private static var isConfigured = false
|
||||
|
||||
/// Memory formatter, uses exact 2 fraction digits and no grouping
|
||||
private static var numberFormatter: NumberFormatter {
|
||||
let formatter = NumberFormatter()
|
||||
@@ -66,15 +64,6 @@ enum ExtensionLogger {
|
||||
return "\(formattedStr) MB"
|
||||
}
|
||||
|
||||
static func configure(currentTarget: String, logLevel: LogLevel) {
|
||||
guard !isConfigured else {
|
||||
return
|
||||
}
|
||||
isConfigured = true
|
||||
|
||||
MXLog.configure(currentTarget: currentTarget, filePrefix: currentTarget, logLevel: logLevel)
|
||||
}
|
||||
|
||||
static func logMemory(with tag: String) {
|
||||
MXLog.info("\(tag) Memory: footprint: \(formattedMemoryFootprint) - available: \(formattedMemoryAvailable)")
|
||||
}
|
||||
|
||||
@@ -14,29 +14,14 @@ import MatrixRustSDK
|
||||
Its purpose is to provide a common entry for customizing logging and should be used throughout the code.
|
||||
*/
|
||||
enum MXLog {
|
||||
private enum Constants {
|
||||
static let target = "elementx"
|
||||
}
|
||||
|
||||
// Rust side crashes if invoking setupTracing multiple times
|
||||
private static var didConfigureOnce = false
|
||||
|
||||
private static var rootSpan: Span!
|
||||
private static var currentTarget: String!
|
||||
|
||||
static func configure(currentTarget: String,
|
||||
filePrefix: String?,
|
||||
logLevel: LogLevel) {
|
||||
guard !didConfigureOnce else { return }
|
||||
|
||||
Tracing.setup(logLevel: logLevel, currentTarget: currentTarget, filePrefix: filePrefix)
|
||||
|
||||
static func configure(currentTarget: String) {
|
||||
self.currentTarget = currentTarget
|
||||
|
||||
rootSpan = Span(file: #file, line: #line, level: .info, target: self.currentTarget, name: "root")
|
||||
rootSpan.enter()
|
||||
|
||||
didConfigureOnce = true
|
||||
}
|
||||
|
||||
static func createSpan(_ name: String,
|
||||
@@ -134,10 +119,6 @@ enum MXLog {
|
||||
function: String = #function,
|
||||
line: Int = #line,
|
||||
column: Int = #column) -> Span {
|
||||
guard didConfigureOnce else {
|
||||
fatalError()
|
||||
}
|
||||
|
||||
if Span.current().isNone() {
|
||||
rootSpan.enter()
|
||||
}
|
||||
@@ -152,7 +133,7 @@ enum MXLog {
|
||||
function: String = #function,
|
||||
line: Int = #line,
|
||||
column: Int = #column) {
|
||||
guard didConfigureOnce else {
|
||||
guard let rootSpan else {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ enum Tracing {
|
||||
|
||||
static let fileExtension = "log"
|
||||
|
||||
static func setup(logLevel: LogLevel, currentTarget: String, filePrefix: String?) {
|
||||
static func buildConfiguration(logLevel: LogLevel, currentTarget: String, filePrefix: String?) -> TracingConfiguration {
|
||||
let fileName = if let filePrefix {
|
||||
"\(Tracing.filePrefix)-\(filePrefix)"
|
||||
} else {
|
||||
@@ -38,13 +38,13 @@ enum Tracing {
|
||||
// the logs contain any sensitive data. See `integration-tests.yml`
|
||||
let level: LogLevel = ProcessInfo.isRunningIntegrationTests ? .trace : logLevel
|
||||
|
||||
setupTracing(config: .init(logLevel: level.rustLogLevel,
|
||||
extraTargets: [currentTarget],
|
||||
writeToStdoutOrSystem: true,
|
||||
writeToFiles: .init(path: logsDirectory.path(percentEncoded: false),
|
||||
filePrefix: fileName,
|
||||
fileSuffix: fileExtension,
|
||||
maxFiles: maxFiles)))
|
||||
return .init(logLevel: level.rustLogLevel,
|
||||
extraTargets: [currentTarget],
|
||||
writeToStdoutOrSystem: true,
|
||||
writeToFiles: .init(path: logsDirectory.path(percentEncoded: false),
|
||||
filePrefix: fileName,
|
||||
fileSuffix: fileExtension,
|
||||
maxFiles: maxFiles))
|
||||
}
|
||||
|
||||
/// A list of all log file URLs, sorted chronologically. This is only public for testing purposes, within
|
||||
|
||||
Reference in New Issue
Block a user