Skip to content

Commit

Permalink
Use the custom log level inside the NSE too. (#2020)
Browse files Browse the repository at this point in the history
  • Loading branch information
pixlwave authored Nov 4, 2023
1 parent ce72a9b commit 5d2215f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ElementX/Sources/Other/SharedUserDefaultsKeys.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
//

enum SharedUserDefaultsKeys: String {
case filterNotificationsByPushRulesEnabled
case logLevel
}
2 changes: 1 addition & 1 deletion NSE/Sources/NotificationServiceExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class NotificationServiceExtension: UNNotificationServiceExtension {
handler = contentHandler
modifiedContent = request.content.mutableCopy() as? UNMutableNotificationContent

NSELogger.configure()
NSELogger.configure(logLevel: settings.logLevel)

NSELogger.logMemory(with: tag)

Expand Down
4 changes: 2 additions & 2 deletions NSE/Sources/Other/NSELogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ class NSELogger {
return "\(formattedStr) MB"
}

static func configure() {
static func configure(logLevel: TracingConfiguration.LogLevel) {
guard !isConfigured else {
return
}
isConfigured = true

MXLog.configure(target: "nse", logLevel: .info)
MXLog.configure(target: "nse", logLevel: logLevel)
}

static func logMemory(with tag: String) {
Expand Down
4 changes: 4 additions & 0 deletions NSE/Sources/Other/NSESettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,8 @@ final class NSESettings {

/// UserDefaults to be used on reads and writes.
private static var store: UserDefaults! = UserDefaults(suiteName: suiteName)

/// The log level that should be used by `MXLog`.
@UserPreference(key: SharedUserDefaultsKeys.logLevel, defaultValue: TracingConfiguration.LogLevel.info, storageType: .userDefaults(store))
var logLevel
}
1 change: 1 addition & 0 deletions changelog.d/pr-2020.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use the custom log level inside the NSE too.

0 comments on commit 5d2215f

Please sign in to comment.