Skip to content

feature: add prefix support in AppleLogger#17

Merged
minjae999 merged 3 commits intomainfrom
feature/prefix
Dec 16, 2025
Merged

feature: add prefix support in AppleLogger#17
minjae999 merged 3 commits intomainfrom
feature/prefix

Conversation

@minjae999
Copy link
Contributor

No description provided.

@minjae999 minjae999 self-assigned this Dec 15, 2025
@coderabbitai
Copy link

coderabbitai bot commented Dec 15, 2025

Walkthrough

ScreenFetcher의 Promise 집계 방식이 Promise.all에서 Promise.tryAll로 바뀌고 Screen 반환이 지역 상수로 바뀌었으며, 로거 설정에 isLegacyLogEnabled가 추가되고 로그 출력(페이징/비페이징)에 공통 헤더·푸터 포맷과 페이징 처리 흐름이 도입되었습니다. Package.swift에서 SabyNetwork 타겟의 SabySafe 의존성이 제거되었고 여러 파일에서 import SabySafe가 삭제되었습니다.

Changes

Cohort / File(s) 요약
Promise 처리 및 Screen 반환 리팩터링
Source/AppleFetcher/Implement/ScreenFetcher.swift
Promise.allPromise.tryAll로 교체; Screen(...) 직접 반환에서 let screen = Screen(...)return screen으로 변경; 주변 포맷팅 조정
로거 설정 속성 추가
Source/AppleLogger/Data/LoggerSetting.swift
LoggerSettingpublic var isLegacyLogEnabled: Bool = false 추가 (기본값 false, init 시그니처 변경 없음)
로거 출력 흐름 및 페이징 처리 변경
Source/AppleLogger/Implement/LogService.swift
페이징 경로에서 headerfooter(예: log={page=...} with id) 형식 도입; 페이징 시 메시지 분할 후 각 라인을 header + line + footer로 매핑해 일괄 출력; 비페이징 경로도 header + message 출력으로 변경; isLegacyLogEnabled에 따라 header 결정
패키지 의존성 변경
Package.swift
SabyNetwork 타겟에서 SabySafe 의존성 제거
불필요한 import 제거(여러 파일)
Source/ApplePreference/Implement/FileValuePreference.swift, Source/AppleStorage/Implement/CoreDataArrayStorage.swift, Source/AppleStorage/Implement/FileValueStorage.swift, Source/Network/Implement/Client/JSONClient.swift
각 파일 상단의 import SabySafe 제거; 코드·API·로직 변경 없음

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30분

  • Source/AppleFetcher/Implement/ScreenFetcher.swift: Promise.tryAll 실패/성공 처리 차이와 호출 맥락 영향 확인
  • Source/AppleLogger/Implement/LogService.swift: 헤더/푸터 포맷, 페이징 분할 로직, ID 생성 및 출력 포맷 검증
  • 여러 파일에서 import SabySafe 제거: 빌드 영향(간접 의존) 검토

Poem

🐰
약속들 고쳐 새 길 닦고,
화면은 조용히 자리를 잡네.
머리글 달아 웃음 건네고,
오래된 방식도 한줄 껴안으며,
토끼는 당근 흔들며 축하하네 🥕

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Title check ⚠️ Warning PR title mentions 'prefix support in AppleLogger' but changes show header-based logging, legacy log enabling, Promise API updates, and dependency removals - the title only partially aligns with the actual main changes. 제목을 변경하여 주요 변경 사항을 더 정확히 반영하세요. 예: 'refactor: restructure AppleLogger with header support and remove SabySafe dependency'
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive PR description is completely empty; no explanation of the changes, objectives, or rationale provided by the author. PR 설명을 작성하여 변경 사항의 목적, 영향을 받는 모듈, 그리고 각 변경의 이유를 명확히 설명하세요.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/prefix

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b009795 and d8064b2.

📒 Files selected for processing (5)
  • Package.swift (1 hunks)
  • Source/ApplePreference/Implement/FileValuePreference.swift (0 hunks)
  • Source/AppleStorage/Implement/CoreDataArrayStorage.swift (0 hunks)
  • Source/AppleStorage/Implement/FileValueStorage.swift (0 hunks)
  • Source/Network/Implement/Client/JSONClient.swift (0 hunks)
💤 Files with no reviewable changes (4)
  • Source/ApplePreference/Implement/FileValuePreference.swift
  • Source/AppleStorage/Implement/CoreDataArrayStorage.swift
  • Source/Network/Implement/Client/JSONClient.swift
  • Source/AppleStorage/Implement/FileValueStorage.swift
🚧 Files skipped from review as they are similar to previous changes (1)
  • Package.swift
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
Source/AppleFetcher/Implement/ScreenFetcher.swift (1)

27-34: 불필요한 중간 변수를 제거하는 것을 고려하세요.

screen 변수를 생성한 후 즉시 반환하는 대신, 직접 반환하는 것이 더 간결합니다.

다음과 같이 리팩토링할 수 있습니다:

         .then { size, scale, orientation in
-            let screen = Screen(
+            return Screen(
                 width: size.width,
                 height: size.height,
                 scale: scale,
                 orientation: orientation.isLandscape ? "landscape": "portrait"
             )
-            
-            return screen
         }
Source/AppleLogger/Data/LoggerSetting.swift (1)

17-19: 정적 분석 도구의 제안을 따라 중복된 초기화를 제거하세요.

SwiftLint가 지적한 대로, 옵셔널 변수는 자동으로 nil로 초기화되므로 명시적인 = nil 초기화는 중복입니다.

정적 분석 도구 힌트에 따라 다음과 같이 수정하세요:

     /// A variable used for displaying prefix value in console.
     /// If `nil` or empty, prefix will not be displayed.
-    public var prefix: String? = nil
+    public var prefix: String?

참고: 문서에는 "nil 또는 empty"인 경우 prefix가 표시되지 않는다고 명시되어 있지만, LogService.swift의 실제 구현에서는 빈 문자열을 체크하지 않습니다. 해당 파일의 리뷰 코멘트를 참조하세요.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e894bb4 and 9d6912d.

📒 Files selected for processing (3)
  • Source/AppleFetcher/Implement/ScreenFetcher.swift (1 hunks)
  • Source/AppleLogger/Data/LoggerSetting.swift (1 hunks)
  • Source/AppleLogger/Implement/LogService.swift (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
Source/AppleLogger/Implement/LogService.swift (2)
Test/AppleLogger/LoggerTest.swift (1)
  • log (90-93)
Source/AppleLogger/Implement/LoggerType.swift (1)
  • log (24-32)
Source/AppleFetcher/Implement/ScreenFetcher.swift (2)
Source/Concurrency/Promise/Composition/PromiseAll.swift (1)
  • tryAll (78-105)
Source/Concurrency/Promise/Promise.swift (1)
  • resolved (357-366)
🪛 SwiftLint (0.57.0)
Source/AppleLogger/Data/LoggerSetting.swift

[Warning] 19-19: Initializing an optional variable with nil is redundant

(redundant_optional_initialization)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: task-list-completed
🔇 Additional comments (1)
Source/AppleFetcher/Implement/ScreenFetcher.swift (1)

21-25: Promise.tryAll 사용이 적절합니다.

현재 코드의 세 개 Promise 모두 이미 Error 실패 타입을 가지고 있으며, Promise.tryAll은 이러한 상황에서 올바른 선택입니다. 가변 개수의 Promise를 여러 실패 타입과 함께 처리하고 Error로 정규화하도록 설계되었습니다. 이 변경은 의도적이며(최근 "error handling 개선" 커밋의 일부), 호출 코드에 영향을 미치지 않습니다.

@minjae999 minjae999 assigned 0xWOF and unassigned 0xWOF Dec 15, 2025
@minjae999 minjae999 requested a review from 0xWOF December 15, 2025 07:23
@minjae999 minjae999 changed the title feature: feature: add prefix support in AppleLogger feature: add prefix support in AppleLogger Dec 15, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
Source/AppleLogger/Implement/LogService.swift (1)

28-28: 최신 Swift 랜덤 API를 사용하세요.

arc4random()은 레거시 함수입니다. Swift의 최신 랜덤 API를 사용하는 것이 권장됩니다.

다음과 같이 수정하세요:

-        let id = arc4random() % 1000000000
+        let id = Int.random(in: 0..<1000000000)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b26c1b6 and ae963ef.

📒 Files selected for processing (4)
  • Package.swift (1 hunks)
  • Source/AppleFetcher/Implement/ScreenFetcher.swift (1 hunks)
  • Source/AppleLogger/Data/LoggerSetting.swift (1 hunks)
  • Source/AppleLogger/Implement/LogService.swift (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • Source/AppleFetcher/Implement/ScreenFetcher.swift
  • Source/AppleLogger/Data/LoggerSetting.swift
🧰 Additional context used
🧬 Code graph analysis (1)
Source/AppleLogger/Implement/LogService.swift (2)
Test/AppleLogger/LoggerTest.swift (1)
  • log (90-93)
Source/AppleLogger/Implement/LoggerType.swift (1)
  • log (24-32)
🪛 SwiftLint (0.57.0)
Source/AppleLogger/Implement/LogService.swift

[Warning] 28-28: Prefer using type.random(in:) over legacy functions

(legacy_random)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: task-list-completed
🔇 Additional comments (4)
Source/AppleLogger/Implement/LogService.swift (3)

21-25: 조기 반환 패턴으로 개선되었습니다.

Guard 문을 사용한 조기 반환 패턴으로 리팩토링되어 가독성이 향상되었습니다.


27-39: 함수형 스타일로 개선되었습니다.

페이지네이션 로직이 map-forEach 파이프라인으로 리팩토링되어 더 선언적이고 읽기 쉬워졌습니다. isLegacyLogEnabled 플래그를 기반으로 헤더를 조건부로 추가하는 로직도 명확합니다.


21-39: 이전 리뷰 코멘트가 현재 코드와 불일치합니다.

이전 리뷰에서 setting.prefix 관련 빈 문자열 처리에 대한 지적이 있었으나, 현재 코드에서는 setting.prefix 속성이 존재하지 않습니다. 대신 isLegacyLogEnabled 플래그를 사용하여 헤더를 조건부로 추가하는 방식으로 변경되었습니다. 이전 코멘트는 더 이상 유효하지 않습니다.

Package.swift (1)

182-182: SabySafe 의존성이 적절하게 사용되고 있습니다.

SabyAppleStorageFileValueStorage.swiftCoreDataArrayStorage.swift에서 SabySafe를 import하고 있으며, SabyApplePreferenceFileValuePreference.swift에서도 SabySafe를 import하고 있습니다. 추가된 의존성이 올바르게 사용 중입니다.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ae963ef and b009795.

📒 Files selected for processing (1)
  • Source/AppleLogger/Implement/LogService.swift (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
Source/AppleLogger/Implement/LogService.swift (2)
Test/AppleLogger/LoggerTest.swift (1)
  • log (90-93)
Source/AppleLogger/Implement/LoggerType.swift (1)
  • log (24-32)
🪛 SwiftLint (0.57.0)
Source/AppleLogger/Implement/LogService.swift

[Warning] 32-32: Prefer using type.random(in:) over legacy functions

(legacy_random)

🔇 Additional comments (3)
Source/AppleLogger/Implement/LogService.swift (3)

31-31: LGTM!

LoggerConstant.paginatedLog 사용으로 페이징 로직이 명확히 분리되어 있습니다.


34-40: LGTM!

함수형 파이프라인을 사용한 페이징 로그 처리가 깔끔하고 명확합니다. map으로 각 페이지에 헤더와 푸터를 추가하고, forEach로 출력하는 구조가 가독성이 좋습니다.


21-27: 비페이징 로그의 헤더 추가는 의도된 기능이며 하위 호환성이 유지됩니다.

코드 변경(line 27에서 header + message 출력)은 새로 도입된 isLegacyLogEnabled 플래그에 의해 제어되는 의도된 기능입니다. 플래그가 기본값 false로 설정되어 있기 때문에 기존 동작은 변경되지 않으며, 헤더 형식 [\(subsystem)][\(category)]\n은 명시적으로 활성화한 경우에만 적용됩니다. 비페이징과 페이징된 로그 경로 모두 헤더를 일관되게 처리하고 있으며(line 38에서도 header + log + footer 형식), 코드베이스에 로그 파싱이나 모니터링 시스템이 없으므로 기존 로그 처리 코드에 영향을 주지 않습니다.


printBlock(message)
let logs = LoggerConstant.paginatedLog(message)
let id = arc4random() % 1000000000
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

레거시 난수 함수를 Swift의 현대적 API로 교체하세요.

arc4random() % 1000000000 대신 Swift의 Int.random(in:) API를 사용하는 것이 권장됩니다. 이는 더 안전하고 Swift의 표준 관행에 부합합니다.

다음과 같이 수정하세요:

-        let id = arc4random() % 1000000000
+        let id = Int.random(in: 0..<1000000000)

Based on static analysis hints from SwiftLint.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let id = arc4random() % 1000000000
let id = Int.random(in: 0..<1000000000)
🧰 Tools
🪛 SwiftLint (0.57.0)

[Warning] 32-32: Prefer using type.random(in:) over legacy functions

(legacy_random)

🤖 Prompt for AI Agents
In Source/AppleLogger/Implement/LogService.swift around line 32, replace the
legacy C-style random generation "let id = arc4random() % 1000000000" with
Swift's modern API by assigning id using Int.random(in: 0..<1_000_000_000); this
removes arc4random usage, matches SwiftLint guidance, and preserves the same
range and integer type.

@minjae999 minjae999 merged commit 46eb93f into main Dec 16, 2025
2 of 4 checks passed
@minjae999 minjae999 deleted the feature/prefix branch December 16, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants