Skip to content

Commit

Permalink
[GWL-52] Logger 모듈 생성 (#101)
Browse files Browse the repository at this point in the history
* feat: Implement Log module

* chore: Change OSLog to
  • Loading branch information
WhiteHyun authored Nov 23, 2023
1 parent e402b17 commit 194c9c2
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public extension TargetDependency {
static let trinet: TargetDependency = .project(target: "Trinet", path: .relativeToCore("Network"))
static let coordinator: TargetDependency = .project(target: "Coordinator", path: .relativeToCore("Coordinator"))
static let combineCocoa: TargetDependency = .project(target: "CombineCocoa", path: .relativeToShared("CombineCocoa"))
static let log: TargetDependency = .project(target: "Log", path: .relativeToShared("Log"))

static func feature(_ feature: Feature) -> TargetDependency {
return .project(
Expand Down
2 changes: 1 addition & 1 deletion iOS/Projects/Features/Record/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let project = Project.makeModule(
targets: .feature(
.record,
testingOptions: [.unitTest],
dependencies: [.trinet, .designSystem, .combineCocoa, .coordinator],
dependencies: [.trinet, .designSystem, .combineCocoa, .coordinator, .log],
testDependencies: [.trinet, .designSystem, .combineCocoa],
resources: "Resources/**"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//

import DesignSystem
import OSLog
import UIKit

// MARK: - WorkoutEnvironmentSetupViewController
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Combine
import CoreLocation
import DesignSystem
import MapKit
import OSLog
import Log
import UIKit

// MARK: - WorkoutRouteMapViewController
Expand Down Expand Up @@ -117,7 +117,7 @@ extension WorkoutRouteMapViewController: CLLocationManagerDelegate {
manager.authorizationStatus == .authorizedWhenInUse
|| manager.authorizationStatus == .authorizedAlways
else {
Logger().error("유저의 위치를 받아올 수 없습니다.")
Log.make().error("유저의 위치를 받아올 수 없습니다.")
return
}
locationManager.startUpdatingLocation()
Expand All @@ -126,7 +126,7 @@ extension WorkoutRouteMapViewController: CLLocationManagerDelegate {
func locationManager(_: CLLocationManager, didUpdateLocations newLocations: [CLLocation]) {
guard let newLocation = newLocations.last
else {
Logger().error("location 값이 존재하지 않습니다.")
Log.make().error("location 값이 존재하지 않습니다.")
return
}

Expand All @@ -145,7 +145,7 @@ extension WorkoutRouteMapViewController: CLLocationManagerDelegate {
}

func locationManager(_: CLLocationManager, didFailWithError error: Error) {
Logger().error("\(error)")
Log.make().error("\(error)")
}
}

Expand Down
7 changes: 7 additions & 0 deletions iOS/Projects/Shared/Log/Project.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import ProjectDescription
import ProjectDescriptionHelpers

let project = Project.makeModule(
name: "Log",
targets: .custom(name: "Log", product: .framework)
)
38 changes: 38 additions & 0 deletions iOS/Projects/Shared/Log/Sources/Logger.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// Log.swift
// DesignSystem
//
// Created by 홍승현 on 11/23/23.
// Copyright © 2023 kr.codesquad.boostcamp8. All rights reserved.
//

import OSLog

/// 로그
public enum Log {

/// Logger를 생성합니다.
/// - Parameter category: Log를 구분하는 Category
public static func make(with category: LogCategory = .default) -> Logger {
return Logger(subsystem: .bundleIdentifier, category: category.rawValue)
}
}


/// 로그 카테고리
public enum LogCategory: String {

/// 기본값으로 들어갑니다.
case `default`

/// UI 로그를 작성할 때 사용합니다.
case userInterface

/// 네트워크 로그를 작성할 때 사용합니다.
case network
}


private extension String {
static let bundleIdentifier: String = Bundle.main.bundleIdentifier ?? "None"
}
8 changes: 0 additions & 8 deletions iOS/Projects/Shared/Project.swift

This file was deleted.

0 comments on commit 194c9c2

Please sign in to comment.