Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logging issue when using managed preferences #538

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions Nudge/Utilities/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,9 @@ struct MemoizationManager {
struct NetworkFileManager {
private func decodeNudgePreferences(from url: URL) -> NudgePreferences? {
guard let data = try? Data(contentsOf: url) else {
LogManager.error("Failed to load data from URL: \(url)", logger: prefsJSONLog)
if Globals.configProfile.isEmpty {
LogManager.error("Failed to load data from URL: \(url)", logger: prefsJSONLog)
}
return nil
}

Expand Down Expand Up @@ -688,17 +690,17 @@ struct NetworkFileManager {
func getNudgeJSONPreferences() -> NudgePreferences? {
let url = getJSONUrl()

LogManager.debug("JSON url: \(url)", logger: utilsLog)

if CommandLineUtilities().demoModeEnabled() || CommandLineUtilities().unitTestingEnabled() {
return nil
}

if CommandLineUtilities().bundleModeEnabled(), let bundleUrl = Globals.bundle.url(forResource: "com.github.macadmins.Nudge.tester", withExtension: "json") {
LogManager.debug("JSON url: \(bundleUrl)", logger: utilsLog)
return decodeNudgePreferences(from: bundleUrl)
}

if let jsonUrl = URL(string: url) {
LogManager.debug("JSON url: \(url)", logger: utilsLog)
return decodeNudgePreferences(from: jsonUrl)
}

Expand Down
Loading