Skip to content

Commit

Permalink
add additional logging for computation
Browse files Browse the repository at this point in the history
  • Loading branch information
erikng committed Jul 25, 2024
1 parent 69421f4 commit 3d618e9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Nudge/UI/Main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,12 @@ class AppDelegate: NSObject, NSApplicationDelegate {
let safeIndex = max(0, minorVersions.count - (OSVersionRequirementVariables.minorVersionRecalculationThreshold + 1)) // Ensure the index is within bounds
let targetVersion = minorVersions[safeIndex]
var foundVersion = false
LogManager.notice("minorVersionRecalculationThreshold is set - Targeting macOS \(targetVersion) requiredInstallationDate via SOFA", logger: sofaLog)
LogManager.notice("minorVersionRecalculationThreshold is set to \(OSVersionRequirementVariables.minorVersionRecalculationThreshold) - Current Version: \(currentInstalledVersion) - Targeting version \(targetVersion) requiredInstallationDate via SOFA", logger: sofaLog)
for osVersion in macOSSOFAAssets {
for securityRelease in osVersion.securityReleases.reversed() {
if VersionManager.versionGreaterThanOrEqual(currentVersion: securityRelease.productVersion, newVersion: targetVersion) && VersionManager.versionLessThan(currentVersion: currentInstalledVersion, newVersion: targetVersion) {
requiredInstallationDate = securityRelease.releaseDate?.addingTimeInterval(slaExtension) ?? DateManager().getCurrentDate().addingTimeInterval(TimeInterval(90 * 86400))
LogManager.notice("Found target macOS version \(targetVersion) - releaseDate is \(securityRelease.releaseDate!), slaExtension is \(LoggerUtilities().printTimeInterval(slaExtension))", logger: sofaLog)
foundVersion = true
break
}
Expand Down
9 changes: 9 additions & 0 deletions Nudge/Utilities/Utils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,15 @@ struct LoggerUtilities {
return PrefsWrapper.requiredMinimumOSVersion == "0.0"
}

func printTimeInterval(_ interval: TimeInterval) -> String {
let days = Int(interval) / (24 * 3600)
let hours = (Int(interval) % (24 * 3600)) / 3600
let minutes = (Int(interval) % 3600) / 60
let seconds = Int(interval) % 60

return "\(days) days, \(hours) hours, \(minutes) minutes, \(seconds) seconds"
}

private func updateDeferralCount(_ count: inout Int, resetCount: Bool, key: String) {
if CommandLineUtilities().demoModeEnabled() {
count = 0
Expand Down

0 comments on commit 3d618e9

Please sign in to comment.