mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Handover log file management to Rust. (#2495)
* Handover log file management to Rust.
Fix all the tests, disabling the logging ones for now.
* Merge logging tests into a single case 😬
Not ideal but at least they're now running.
* Move TracingConfiguration into its own file.
* Split up the tests into smaller functions instead of writing code like a caveman.
This commit is contained in:
@@ -24,15 +24,6 @@ import MatrixRustSDK
|
||||
enum MXLog {
|
||||
private enum Constants {
|
||||
static let target = "elementx"
|
||||
|
||||
// Avoid redirecting NSLogs to files if we are attached to a debugger.
|
||||
static let redirectToFiles = isatty(STDERR_FILENO) == 0
|
||||
|
||||
/// the maximum number of log files to use before rolling. `10` by default.
|
||||
static let maxLogFileCount: UInt = 10
|
||||
|
||||
/// the maximum total space to use for log files in bytes. `100MB` by default.
|
||||
static let logFilesSizeLimit: UInt = 100 * 1024 * 1024 // 100MB
|
||||
}
|
||||
|
||||
// Rust side crashes if invoking setupTracing multiple times
|
||||
@@ -43,39 +34,20 @@ enum MXLog {
|
||||
|
||||
static func configure(target: String? = nil,
|
||||
logLevel: TracingConfiguration.LogLevel,
|
||||
otlpConfiguration: OTLPConfiguration? = nil,
|
||||
redirectToFiles: Bool = Constants.redirectToFiles,
|
||||
maxLogFileCount: UInt = Constants.maxLogFileCount,
|
||||
logFileSizeLimit: UInt = Constants.logFilesSizeLimit) {
|
||||
guard didConfigureOnce == false else {
|
||||
if let target {
|
||||
MXLogger.setSubLogName(target)
|
||||
}
|
||||
|
||||
// SubLogName needs to be set before calling configure in order to be applied
|
||||
MXLogger.configure(redirectToFiles: redirectToFiles,
|
||||
maxLogFileCount: maxLogFileCount,
|
||||
logFileSizeLimit: logFileSizeLimit)
|
||||
return
|
||||
}
|
||||
otlpConfiguration: OTLPConfiguration? = nil) {
|
||||
guard !didConfigureOnce else { return }
|
||||
|
||||
RustTracing.setup(configuration: .init(logLevel: logLevel), otlpConfiguration: otlpConfiguration)
|
||||
RustTracing.setup(configuration: .init(logLevel: logLevel, target: target), otlpConfiguration: otlpConfiguration)
|
||||
|
||||
if let target {
|
||||
self.target = target
|
||||
MXLogger.setSubLogName(target)
|
||||
} else {
|
||||
self.target = Constants.target
|
||||
}
|
||||
|
||||
rootSpan = Span(file: #file, line: #line, level: .info, target: self.target, name: "root")
|
||||
|
||||
rootSpan.enter()
|
||||
|
||||
MXLogger.configure(redirectToFiles: redirectToFiles,
|
||||
maxLogFileCount: maxLogFileCount,
|
||||
logFileSizeLimit: logFileSizeLimit)
|
||||
|
||||
didConfigureOnce = true
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user