Files
letro-ios/ElementX/Sources/Application/TargetConfiguration.swift
Stefan Ceriu 4c7791ab24 Fix various small errors when running in the Swift 6 language mode (#4109)
* Fix various small errors when running in the Swift 6 language mode

* Make the `TargetConfiguration` run on the main actor.

* Fixed a comment

* Add a comment as to why we can't make the whole NSE a main actor.

* Fix the unit tests

* Fix `blankLinesAtStartOfScope` swiftformat error.
2025-05-13 11:43:47 +03:00

56 lines
2.5 KiB
Swift

//
// Copyright 2022-2024 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 MatrixRustSDK
@MainActor
enum Target: String {
case mainApp = "elementx"
case nse
case shareExtension = "shareextension"
case tests
private static var isConfigured = false
func configure(logLevel: LogLevel, traceLogPacks: Set<TraceLogPack>) {
guard !Self.isConfigured else {
return
}
switch self {
case .mainApp:
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,
traceLogPacks: traceLogPacks,
currentTarget: rawValue,
filePrefix: rawValue)
initPlatform(config: tracingConfiguration, useLightweightTokioRuntime: true)
case .shareExtension:
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,
traceLogPacks: traceLogPacks,
currentTarget: rawValue,
filePrefix: rawValue)
initPlatform(config: tracingConfiguration, useLightweightTokioRuntime: false)
}
MXLog.configure(currentTarget: rawValue)
Self.isConfigured = true
}
}