Skip to content

Commit

Permalink
🚚 RecordingJourneyStorage ➡️ recordingJourneyService로 네이밍 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
SwiftyJunnos committed Jan 29, 2024
1 parent 3580953 commit 9690880
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public struct JourneyRepositoryImplementation: JourneyRepository {
private let networking: MSNetworking
private let storage: MSPersistentStorage

private var recordingJourney: RecordingJourneyStorage
private var recordingJourney: RecordingJourneyService

public var isRecording: Bool {
return self.recordingJourney.isRecording
Expand All @@ -36,7 +36,7 @@ public struct JourneyRepositoryImplementation: JourneyRepository {
persistentStorage: MSPersistentStorage = FileManagerStorage()) {
self.networking = MSNetworking(session: session)
self.storage = persistentStorage
self.recordingJourney = RecordingJourneyStorage.shared
self.recordingJourney = RecordingJourneyService.shared
}

// MARK: - Functions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public struct SpotRepositoryImplementation: SpotRepository {
#if DEBUG
MSLogger.make(category: .network).debug("성공적으로 업로드하였습니다.")
#endif
RecordingJourneyStorage.shared.record([spot], keyPath: \.spots)
RecordingJourneyService.shared.record([spot], keyPath: \.spots)
return .success(spot.toDomain())
case .failure(let error):
MSLogger.make(category: .network).error("\(error): 업로드에 실패하였습니다.")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// RecordingJourneyStorage.swift
// RecordingJourneyService.swift
// MSData
//
// Created by 전민건 on 2023.12.10.
Expand All @@ -15,7 +15,7 @@ import MSUserDefaults

// MARK: - Default Implementations

public struct RecordingJourneyStorage {
public struct RecordingJourneyService {

// MARK: - Properties

Expand Down Expand Up @@ -45,7 +45,7 @@ public struct RecordingJourneyStorage {

// MARK: - Shared

public static let shared = RecordingJourneyStorage()
public static let shared = RecordingJourneyService()

// MARK: - Functions

Expand All @@ -57,7 +57,7 @@ public struct RecordingJourneyStorage {
do {
try self.finish()
} catch {
MSLogger.make(category: .recordingJourneyStorage)
MSLogger.make(category: .recordingJourneyService)
.warning("삭제되지 않은 이전 여정 기록 초기화에 실패했습니다.")
}
}
Expand All @@ -71,19 +71,19 @@ public struct RecordingJourneyStorage {
forKey: startTimestampKey,
subpath: recordingJourney.id)
} catch {
MSLogger.make(category: .recordingJourneyStorage)
MSLogger.make(category: .recordingJourneyService)
.error("여정 기록 시작 Timestamp를 기록할 수 없습니다: \(recordingJourney.startTimestamp)")
}
} else {
MSLogger.make(category: .recordingJourneyStorage)
MSLogger.make(category: .recordingJourneyService)
.warning("Start Timestamp에 대한 기록이 실패했습니다.")
}
}

@discardableResult
public func record<T: Codable>(_ values: [T], keyPath: KeyPath<RecordingJourneyDTO, [T]>) -> Bool {
guard let recordingJourneyID = self.recordingJourneyID else {
MSLogger.make(category: .recordingJourneyStorage)
MSLogger.make(category: .recordingJourneyService)
.error("recordingJourneyID를 조회할 수 없습니다. 여정이 기록 중인지 확인해주세요.")
return false
}
Expand All @@ -97,7 +97,7 @@ public struct RecordingJourneyStorage {
forKey: key,
subpath: recordingJourneyID)
} catch {
MSLogger.make(category: .recordingJourneyStorage)
MSLogger.make(category: .recordingJourneyService)
.error("여정 좌표를 기록할 수 없습니다: \(recordingValues)")
}
return true
Expand All @@ -114,15 +114,15 @@ public struct RecordingJourneyStorage {
self.recordingJourneyID = nil

#if DEBUG
MSLogger.make(category: .recordingJourneyStorage).debug("여정 기록을 종료합니다: \(recordingJourneyID)")
MSLogger.make(category: .recordingJourneyService).debug("여정 기록을 종료합니다: \(recordingJourneyID)")
#endif
}

}

// MARK: - Private Functions

private extension RecordingJourneyStorage {
private extension RecordingJourneyService {

private enum Prefix {
static let idKey = "id"
Expand Down Expand Up @@ -158,7 +158,7 @@ private extension RecordingJourneyStorage {
let startTimestamp = try? self.storage.get(Date.self,
forKey: startTimestampKey,
subpath: recordingJourneyID) else {
MSLogger.make(category: .recordingJourneyStorage)
MSLogger.make(category: .recordingJourneyService)
.warning("기록중인 여정에서 StartTimestamp를 불러오지 못했습니다.")
return nil
}
Expand All @@ -171,7 +171,7 @@ private extension RecordingJourneyStorage {
let spots = try? self.storage.get([SpotDTO].self,
forKey: spotKey,
subpath: recordingJourneyID) else {
MSLogger.make(category: .recordingJourneyStorage)
MSLogger.make(category: .recordingJourneyService)
.warning("기록중인 여정에서 Spot 목록을 불러오지 못했습니다.")
return []
}
Expand All @@ -185,7 +185,7 @@ private extension RecordingJourneyStorage {
let coordinates = try? self.storage.get([CoordinateDTO].self,
forKey: coordinateKey,
subpath: recordingJourneyID) else {
MSLogger.make(category: .recordingJourneyStorage)
MSLogger.make(category: .recordingJourneyService)
.warning("기록중인 여정에서 Coordinate 목록을 불러오지 못했습니다.")
return []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ final class PersistentManagerTests: XCTestCase {
// MARK: - Properties

private let storage = FileManagerStorage()
private var recordingJourney = RecordingJourneyStorage.shared
private var recordingJourney = RecordingJourneyService.shared

override func tearDown() async throws {
try self.recordingJourney.finish()
Expand Down
2 changes: 1 addition & 1 deletion iOS/MSFoundation/Sources/MSLogger/MSLogCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public enum MSLogCategory: String {
case userDefaults
case keychain = "Keychain"
case fileManager = "FileManager"
case recordingJourneyStorage = "RecordingJourneyStorage"
case recordingJourneyService = "RecordingJourneyService"
case music = "MusicKit"

case home
Expand Down

0 comments on commit 9690880

Please sign in to comment.