소스 검색

Refactor class to use protocol

pull/212/head
Angelo Stavrow 1 년 전
부모
커밋
b93e0c3547
No known key found for this signature in database GPG 키 ID: 1A49C7064E060EEE
1개의 변경된 파일12개의 추가작업 그리고 2개의 파일을 삭제
  1. +12
    -2
      Shared/Logging/Logging.swift

+ 12
- 2
Shared/Logging/Logging.swift 파일 보기

@@ -7,16 +7,26 @@

import Foundation
import os
import OSLog

protocol LogWriter {
func log(_ message: String, withSensitiveInfo privateInfo: String?, level: OSLogType)
func logCrashAndSetFlag(error: Error)
}

final class Logging {

private let logger: Logger
private let subsystem = Bundle.main.bundleIdentifier!

init(for category: String) {
init(for category: String = "") {
self.logger = Logger(subsystem: subsystem, category: category)
}

}

extension Logging: LogWriter {

func log(
_ message: String,
withSensitiveInfo privateInfo: String? = nil,
@@ -33,7 +43,7 @@ final class Logging {
let errorDescription = error.localizedDescription
UserDefaults.shared.set(true, forKey: WFDefaults.didHaveFatalError)
UserDefaults.shared.set(errorDescription, forKey: WFDefaults.fatalErrorDescription)
logger.critical("\(errorDescription)")
logger.log(level: .error, "\(errorDescription)")
fatalError(errorDescription)
}



불러오는 중...
취소
저장