Skip to content

Conversation

@youn9k
Copy link
Member

@youn9k youn9k commented Dec 1, 2024

🤔 배경

Logger와 DIContainer, 공통 Extension 등 모든 모듈에서 사용가능한 범용적인 코드들을 둘 곳이 없었습니다.
그로인해 각 모듈마다 중복된 코드가 생성되고 있어 공통 모듈을 두어 문제를 해결합니다.

📃 작업 내역

  • CoreModule 생성 (모든 모듈에서 의존 가능합니다. 대신 CoreModule에 코드를 추가할 때 상의해야함)
  • PTGLogger 추가 (PTGDataLogger -> PTGLogger 로 리팩토링)

아래와 같이 사용 가능합니다.

PTGLogger.default.log("방 참가 요청 데이터 인코딩 실패: \(joinRoomRequest)") // default를 사용 시 subsystem, category 고정
PTGLogger.default.log("Unknown Decoding error: \(error.localizedDescription)", level: .debug)
PTGLogger(category: "Presentation").log("화면이 안보여요", level: .error) // category와 subsystem을 직접 설정 가능
public struct PTGLogger {
    private let logger: Logger

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

    public func log(
        _ message: String,
        level: OSLogType = .error,
        file: String = #file,
        function: String = #function,
        line: Int = #line
    ) {
        let fileName = (file as NSString).lastPathComponent
        logger.log(
            level: level,
            "[ 🚀 LOG ] \(fileName, privacy: .public):\(line) | \(function) | \(message, privacy: .public)"
        )
    }
}

public extension PTGLogger {
    static let `default` = PTGLogger(subsystem: "PhotoGether", category: "Default")
}

✅ 리뷰 노트

@youn9k youn9k added the ✨ feat 새로운 기능 추가 label Dec 1, 2024
@youn9k youn9k self-assigned this Dec 1, 2024
@youn9k youn9k linked an issue Dec 1, 2024 that may be closed by this pull request
1 task
Copy link
Collaborator

@hsw1920 hsw1920 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 피쳐에서도 로거를 사용해보도록 하겠습니다!

Copy link
Collaborator

@0Hooni 0Hooni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

로거 생겼다 ㅅㅅㅅ

코어 추가/수정에 대한 그라운드룰도 숙지 완료입니다 ☺️

LGTM 👍

Base automatically changed from feature/#151-participants-layout-sync to develop December 2, 2024 00:58
@youn9k youn9k merged commit 525bda0 into develop Dec 2, 2024
1 check failed
@youn9k youn9k deleted the feat/#155-core-module branch December 2, 2024 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ feat 새로운 기능 추가

Projects

None yet

Development

Successfully merging this pull request may close these issues.

모든 모듈에서 공통으로 접근가능한 코어 모듈을 생성합니다.

4 participants