Skip to content

Commit

Permalink
feat: apply setDebugErrorPrintEnabled to control unnecessary print st…
Browse files Browse the repository at this point in the history
…atement
  • Loading branch information
jwhwangbirdview committed Apr 6, 2023
1 parent 706cbc1 commit 147a3c3
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions netfox/Core/NFXHTTPModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ fileprivate func < <T : Comparable>(lhs: T?, rhs: T?) -> Bool {

public var timeInterval: Float?

private static var debugErrorPrintEnabled: Bool = true

@objc public lazy var randomHash = UUID().uuidString
public var shortType = HTTPModelShortType.OTHER
@objc public var shortTypeString: String { return shortType.rawValue }

@objc public var noResponse = true

public static func setDebugErrorPrintEnabled(with enabled: Bool) {
debugErrorPrintEnabled = enabled
}

func saveRequest(_ request: URLRequest) {
requestDate = Date()
requestTime = getTimeFromDate(requestDate!)
Expand Down Expand Up @@ -166,15 +172,19 @@ fileprivate func < <T : Comparable>(lhs: T?, rhs: T?) -> Bool {
do {
try dataString.write(to: fileURL, atomically: true, encoding: .utf8)
} catch let error {
print("[NFX]: Failed to save data to [\(fileURL)] - \(error.localizedDescription)")
if NFXHTTPModel.debugErrorPrintEnabled {
print("[NFX]: Failed to save data to [\(fileURL)] - \(error.localizedDescription)")
}
}
}

@objc public func readRawData(from fileURL: URL) -> Data? {
do {
return try Data(contentsOf: fileURL)
} catch let error {
print("[NFX]: Failed to load data from [\(fileURL)] - \(error.localizedDescription)")
if NFXHTTPModel.debugErrorPrintEnabled {
print("[NFX]: Failed to load data from [\(fileURL)] - \(error.localizedDescription)")
}
return nil
}
}
Expand Down

0 comments on commit 147a3c3

Please sign in to comment.