[diagnostics]: make operations logging into console to be conditional, toggled by a switch in settings

This commit is contained in:
Magesh K
2025-01-02 20:48:25 +05:30
parent 74749b6502
commit a967a7aaad
4 changed files with 98 additions and 48 deletions

View File

@@ -38,10 +38,13 @@ class ResultOperation<ResultType>: Operation
result = .failure(error)
}
// diagnostics logging
let resultStatus = String(describing: result).prefix("success".count).uppercased()
print("\n ====> OPERATION: `\(type(of: self))` completed with: \(resultStatus) <====\n\n" +
" Result: \(result)\n")
// Diagnostics: perform verbose logging of the operations only if enabled (so as to not flood console logs)
if UserDefaults.standard.isVerboseOperationsLoggingEnabled {
// diagnostics logging
let resultStatus = String(describing: result).prefix("success".count).uppercased()
print("\n ====> OPERATION: `\(type(of: self))` completed with: \(resultStatus) <====\n\n" +
" Result: \(result)\n")
}
self.resultHandler?(result)