Digital PCT265 story ONEAPP-7249 - CoreLogging protocol for easier logging.

This commit is contained in:
Hedden, Kyle Matthew 2024-04-30 13:42:33 -04:00
parent fe7e98f615
commit 39a8451314
2 changed files with 35 additions and 0 deletions

View File

@ -116,3 +116,13 @@ public struct ActionOpenPageModel: ActionModelProtocol, ActionOpenPageProtocol,
try container.encodeIfPresent(fallbackResponse, forKey: .fallbackResponse)
}
}
extension ActionOpenPageModel: CustomDebugStringConvertible {
public var debugDescription: String {
if let requestURL {
return "\(Self.self) for \(pageType) @ \(requestURL)"
} else {
return "\(Self.self) for \(pageType)"
}
}
}

View File

@ -13,3 +13,28 @@ import Foundation
Swift.print(message)
}
}
public protocol CoreLogging {
func debugLog(_ string: String)
var loggingPrefix: String { get }
}
public extension CoreLogging {
var loggingPrefix: String {
return String(describing: self)
}
static func debugLog(_ string: String) {
#if LOGGING
MVMCoreLoggingHandler.shared()?.handleDebugMessage("\(String(describing: Self.self)) \(string)")
#endif
}
func debugLog(_ string: String) {
#if LOGGING
MVMCoreLoggingHandler.shared()?.handleDebugMessage("\(loggingPrefix) " + string)
#endif
}
}