-
Notifications
You must be signed in to change notification settings - Fork 0
Setting/#9 Logger #16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| objects = { | ||
|
|
||
| /* Begin PBXFileReference section */ | ||
| 5126F89E2F0E9AF000E67E33 /* OSLog.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OSLog.framework; path = System/Library/Frameworks/OSLog.framework; sourceTree = SDKROOT; }; | ||
| 51B5D3182F0514390090B8B4 /* Cherrish-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Cherrish-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; | ||
| /* End PBXFileReference section */ | ||
|
|
||
|
|
@@ -42,10 +43,19 @@ | |
| /* End PBXFrameworksBuildPhase section */ | ||
|
|
||
| /* Begin PBXGroup section */ | ||
| 5126F89D2F0E9AF000E67E33 /* Frameworks */ = { | ||
| isa = PBXGroup; | ||
| children = ( | ||
| 5126F89E2F0E9AF000E67E33 /* OSLog.framework */, | ||
| ); | ||
| name = Frameworks; | ||
| sourceTree = "<group>"; | ||
| }; | ||
| 51B5D30F2F0514390090B8B4 = { | ||
| isa = PBXGroup; | ||
| children = ( | ||
| 51B5D31A2F0514390090B8B4 /* Cherrish-iOS */, | ||
| 5126F89D2F0E9AF000E67E33 /* Frameworks */, | ||
| 51B5D3192F0514390090B8B4 /* Products */, | ||
| ); | ||
| sourceTree = "<group>"; | ||
|
|
@@ -262,10 +272,12 @@ | |
| buildSettings = { | ||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; | ||
| CODE_SIGN_STYLE = Automatic; | ||
| "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; | ||
| CODE_SIGN_STYLE = Manual; | ||
| CURRENT_PROJECT_VERSION = 1; | ||
| DEVELOPMENT_ASSET_PATHS = ""; | ||
| DEVELOPMENT_TEAM = CG37U6CMKP; | ||
| DEVELOPMENT_TEAM = ""; | ||
| "DEVELOPMENT_TEAM[sdk=iphoneos*]" = CG37U6CMKP; | ||
| ENABLE_PREVIEWS = YES; | ||
|
Comment on lines
+275
to
281
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐งน Nitpick | ๐ต Trivial ์๋ ์ฝ๋ ์๋ช ์ค์ ์ ํ์ธํ์ธ์. ์ฝ๋ ์๋ช ๋ฐฉ์์ด Automatic์์ Manual๋ก ๋ณ๊ฒฝ๋์๊ณ , ๊ฐ๋ฐ ํ ๋ฐ ํ๋ก๋น์ ๋ ํ๋กํ์ผ์ด ์ค์ ๋์์ต๋๋ค. ์ด๋ฌํ ๋ณ๊ฒฝ์ฌํญ์:
ํ ์ ์ฒด๊ฐ ๋์ผํ ํ๋ก๋น์ ๋ ํ๋กํ์ผ๊ณผ ์ธ์ฆ์์ ์ก์ธ์คํ ์ ์๋์ง ํ์ธํ์ธ์. Also applies to: 302-303 ๐ค Prompt for AI Agents |
||
| GENERATE_INFOPLIST_FILE = YES; | ||
| INFOPLIST_FILE = "Cherrish-iOS/Info.plist"; | ||
|
|
@@ -282,6 +294,8 @@ | |
| MARKETING_VERSION = 1.0; | ||
| PRODUCT_BUNDLE_IDENTIFIER = "com.nayeon.Cherrish-iOS"; | ||
| PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| PROVISIONING_PROFILE_SPECIFIER = ""; | ||
| "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "cherrish-development"; | ||
| SWIFT_EMIT_LOC_STRINGS = YES; | ||
| SWIFT_VERSION = 5.0; | ||
| TARGETED_DEVICE_FAMILY = "1,2"; | ||
|
|
@@ -293,10 +307,12 @@ | |
| buildSettings = { | ||
| ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; | ||
| ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; | ||
| CODE_SIGN_STYLE = Automatic; | ||
| "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution"; | ||
| CODE_SIGN_STYLE = Manual; | ||
| CURRENT_PROJECT_VERSION = 1; | ||
| DEVELOPMENT_ASSET_PATHS = ""; | ||
| DEVELOPMENT_TEAM = CG37U6CMKP; | ||
| DEVELOPMENT_TEAM = ""; | ||
| "DEVELOPMENT_TEAM[sdk=iphoneos*]" = CG37U6CMKP; | ||
| ENABLE_PREVIEWS = YES; | ||
| GENERATE_INFOPLIST_FILE = YES; | ||
| INFOPLIST_FILE = "Cherrish-iOS/Info.plist"; | ||
|
|
@@ -313,6 +329,8 @@ | |
| MARKETING_VERSION = 1.0; | ||
| PRODUCT_BUNDLE_IDENTIFIER = "com.nayeon.Cherrish-iOS"; | ||
| PRODUCT_NAME = "$(TARGET_NAME)"; | ||
| PROVISIONING_PROFILE_SPECIFIER = ""; | ||
| "PROVISIONING_PROFILE_SPECIFIER[sdk=iphoneos*]" = "cherrish-distribution"; | ||
| SWIFT_EMIT_LOC_STRINGS = YES; | ||
| SWIFT_VERSION = 5.0; | ||
| TARGETED_DEVICE_FAMILY = "1,2"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,43 @@ | ||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||
| // CherrishError.swift | ||||||||||||||||||||||||||||||||||||||||||
| // Cherrish-iOS | ||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||
| // Created by ์ด๋์ฐ on 1/8/26. | ||||||||||||||||||||||||||||||||||||||||||
| // | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import Foundation | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| enum CherrishError: Error, LocalizedError, Equatable { | ||||||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ ๏ธ Refactor suggestion | ๐ Major ์ ๊ทผ ์ ์ด์๋ฅผ ๋ช ์ํ์ธ์. ์ด ์๋ฌ ํ์
์ด ํ๋ก์ ํธ ์ ์ฒด์์ ์ฌ์ฉ๋ ๊ฒ์ผ๋ก ๋ณด์ด๋ฏ๋ก, โป๏ธ ์ ์ํ๋ ์์ -enum CherrishError: Error, LocalizedError, Equatable {
+public enum CherrishError: Error, LocalizedError, Equatable {๐ค Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
| case DIFailedError | ||||||||||||||||||||||||||||||||||||||||||
| case decodingError | ||||||||||||||||||||||||||||||||||||||||||
| case URLError | ||||||||||||||||||||||||||||||||||||||||||
| case networkRequestFailed | ||||||||||||||||||||||||||||||||||||||||||
| case networkConnect | ||||||||||||||||||||||||||||||||||||||||||
| case networkError(code: Int, message: String) | ||||||||||||||||||||||||||||||||||||||||||
| case noData | ||||||||||||||||||||||||||||||||||||||||||
| case unknownError | ||||||||||||||||||||||||||||||||||||||||||
| case encodingError | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+10
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ ๏ธ Refactor suggestion | ๐ Major ์ ๊ทผ ์ ์ด์๋ฅผ ๋ช ์ํ์ธ์. ์ด ์๋ฌ ํ์
์ด ํ๋ก์ ํธ ์ ์ฒด์์ ์ฌ์ฉ๋ ๊ฒ์ผ๋ก ๋ณด์ด๋ฏ๋ก, โป๏ธ ์ ์ํ๋ ์์ -enum CherrishError: Error, LocalizedError, Equatable {
+public enum CherrishError: Error, LocalizedError, Equatable {๐ Committable suggestion
Suggested change
๐ค Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| var errorDescription: String? { | ||||||||||||||||||||||||||||||||||||||||||
| switch self { | ||||||||||||||||||||||||||||||||||||||||||
| case .DIFailedError: | ||||||||||||||||||||||||||||||||||||||||||
| return "์์กด์ฑ ์ฃผ์ ์คํจ" | ||||||||||||||||||||||||||||||||||||||||||
| case .decodingError: | ||||||||||||||||||||||||||||||||||||||||||
| return "๋์ฝ๋ฉ ์คํจ" | ||||||||||||||||||||||||||||||||||||||||||
| case .URLError: | ||||||||||||||||||||||||||||||||||||||||||
| return "URL ๋ณํ ์คํจ" | ||||||||||||||||||||||||||||||||||||||||||
| case .networkRequestFailed: | ||||||||||||||||||||||||||||||||||||||||||
| return "๋คํธ์ํฌ ์์ฒญ ์คํจ" | ||||||||||||||||||||||||||||||||||||||||||
| case .networkConnect: | ||||||||||||||||||||||||||||||||||||||||||
| return "๋คํธ์ํฌ ์ฐ๊ฒฐ ์๋ฌ" | ||||||||||||||||||||||||||||||||||||||||||
| case .networkError(let code, let message): | ||||||||||||||||||||||||||||||||||||||||||
| return "\(code): \(message)" | ||||||||||||||||||||||||||||||||||||||||||
| case .noData: | ||||||||||||||||||||||||||||||||||||||||||
| return "๋ฐ์ดํฐ ์์" | ||||||||||||||||||||||||||||||||||||||||||
| case .encodingError: | ||||||||||||||||||||||||||||||||||||||||||
| return "์ธ์ฝ๋ฉ ์คํจ" | ||||||||||||||||||||||||||||||||||||||||||
| case .unknownError: | ||||||||||||||||||||||||||||||||||||||||||
| return "์ ์ ์๋ ์ค๋ฅ" | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,3 +5,150 @@ | |||||
| // Created by ์ด๋์ฐ on 12/31/25. | ||||||
| // | ||||||
|
|
||||||
| import OSLog | ||||||
|
|
||||||
| extension OSLog { | ||||||
| static let subsystem = Bundle.main.bundleIdentifier! | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bundleIdentifier ๊ฐ์ ์ธ๋ํ์ด ์ํํฉ๋๋ค.
๐ ์ ์ํ๋ ์์ - static let subsystem = Bundle.main.bundleIdentifier!
+ static let subsystem = Bundle.main.bundleIdentifier ?? "com.cherrish.unknown"๐ Committable suggestion
Suggested change
๐ค Prompt for AI Agents |
||||||
| static let network = OSLog(subsystem: subsystem, category: "Network") | ||||||
| static let debug = OSLog(subsystem: subsystem, category: "Debug") | ||||||
| static let data = OSLog(subsystem: subsystem, category: "Data") | ||||||
| static let error = OSLog(subsystem: subsystem, category: "Error") | ||||||
| } | ||||||
|
|
||||||
| enum LogType { | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐ ๏ธ Refactor suggestion | ๐ Major LogType๊ณผ CherrishLogger์ ์ ๊ทผ ์ ์ด์๋ฅผ ๋ช ์ํ์ธ์. ์ด ํ์
๋ค์ด ํ๋ก์ ํธ ์ ์ฒด์์ ์ฌ์ฉ๋๋ฏ๋ก โป๏ธ ์ ์ํ๋ ์์ -enum LogType {
+public enum LogType {
case network
case debug
case data
case error(error: Error)
// ...
}
-struct CherrishLogger {
+public struct CherrishLogger {
// ...
}Also applies to: 71-71 ๐ค Prompt for AI Agents |
||||||
| case network | ||||||
| case debug | ||||||
| case data | ||||||
| case error(error: Error) | ||||||
|
|
||||||
| var category: String { | ||||||
| switch self { | ||||||
| case .network: | ||||||
| return "Network" | ||||||
| case .debug: | ||||||
| return "Debug" | ||||||
| case .data: | ||||||
| return "Data" | ||||||
| case .error: | ||||||
| return "Error" | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| var osLog: OSLog { | ||||||
| switch self { | ||||||
| case .network: | ||||||
| return OSLog.network | ||||||
| case .debug: | ||||||
| return OSLog.debug | ||||||
| case .data: | ||||||
| return OSLog.data | ||||||
| case .error: | ||||||
| return OSLog.error | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| var osLogType: OSLogType { | ||||||
| switch self { | ||||||
| case .network, .data: | ||||||
| return .default | ||||||
| case .debug: | ||||||
| return .debug | ||||||
| case .error: | ||||||
| return .error | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| var shouldShowLogInRelease: Bool { | ||||||
| switch self { | ||||||
| case .error: | ||||||
| true | ||||||
| default: | ||||||
| false | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| struct CherrishLogger { | ||||||
| private static var isDebugMode: Bool { | ||||||
| #if DEBUG | ||||||
| return true | ||||||
| #else | ||||||
| return false | ||||||
| #endif | ||||||
| } | ||||||
|
|
||||||
| private static func shouldShowLog(type: LogType) -> Bool { | ||||||
| if isDebugMode { return true } | ||||||
|
|
||||||
| return type.shouldShowLogInRelease | ||||||
| } | ||||||
|
|
||||||
| private static let dateFormatter: DateFormatter = { | ||||||
| let formatter = DateFormatter() | ||||||
| formatter.dateFormat = "yyyy/MM/dd HH:mm:ss" | ||||||
| formatter.locale = Locale(identifier: "en_US_POSIX") | ||||||
| return formatter | ||||||
| }() | ||||||
|
|
||||||
| private static var timestamp: String { | ||||||
| dateFormatter.string(from: Date()) | ||||||
| } | ||||||
|
|
||||||
| static private func log( | ||||||
| type: LogType, | ||||||
| message: Any, | ||||||
| file: String, | ||||||
| function: String | ||||||
|
|
||||||
| ) { | ||||||
| guard shouldShowLog(type: type) else { return } | ||||||
|
|
||||||
| let logger = Logger(subsystem: OSLog.subsystem, category: type.category) | ||||||
| let logMessage = "\(message)" | ||||||
| let fileName = (file as NSString).lastPathComponent | ||||||
|
|
||||||
| switch type { | ||||||
| case .network: | ||||||
| logger.log("[๐ Network] [Date: \(timestamp)] [\(fileName) -> \(function)]: \(logMessage)") | ||||||
| case .debug: | ||||||
| logger.debug("[๐ Debug] [Date: \(timestamp)] [\(fileName) -> \(function)]: \(logMessage)") | ||||||
| case .data: | ||||||
| logger.info("[๐ Data] [Date: \(timestamp)] [\(fileName) -> \(function)]: \(logMessage)") | ||||||
| case .error(let error): | ||||||
| logger.error("[โ Error] [Date: \(timestamp)] [\(fileName) -> \(function)]: \(error.localizedDescription)") | ||||||
|
|
||||||
| } | ||||||
| } | ||||||
|
|
||||||
| static func network( | ||||||
| _ message: Any, | ||||||
| file: String = #file, | ||||||
| function: String = #function | ||||||
| ) { | ||||||
| log(type: .network, message: message, file: file, function: function) | ||||||
| } | ||||||
|
|
||||||
| static func debug( | ||||||
| _ message: Any, | ||||||
| file: String = #file, | ||||||
| function: String = #function | ||||||
| ) { | ||||||
| log(type: .debug, message: message, file: file, function: function) | ||||||
| } | ||||||
|
|
||||||
| static func data( | ||||||
| _ message: Any, | ||||||
| file: String = #file, | ||||||
| function: String = #function | ||||||
| ) { | ||||||
| log(type: .data, message: message, file: file, function: function) | ||||||
| } | ||||||
|
|
||||||
| static func error( | ||||||
| _ error: Error, | ||||||
| file: String = #file, | ||||||
| function: String = #function | ||||||
| ) { | ||||||
| log(type: .error(error: error), message: "", file: file, function: function) | ||||||
| } | ||||||
|
Comment on lines
+147
to
+153
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ๐งน Nitpick | ๐ต Trivial error ํจ์์ message ํ๋ผ๋ฏธํฐ ์ฌ์ฉ์ ๊ณ ๋ คํ์ธ์. ํ์ฌ โป๏ธ ์ ์ํ๋ ์์ static func error(
_ error: Error,
+ message: Any = "",
file: String = #file,
function: String = #function
) {
- log(type: .error(error: error), message: "", file: file, function: function)
+ log(type: .error(error: error), message: message, file: file, function: function)
}๊ทธ๋ฆฌ๊ณ case .error(let error):
- logger.error("[โ Error] [Date: \(timestamp)] [\(fileName) -> \(function)]: \(error.localizedDescription)")
+ let contextMessage = logMessage.isEmpty ? "" : "[\(logMessage)] "
+ logger.error("[โ Error] [Date: \(timestamp)] [\(fileName) -> \(function)]: \(contextMessage)\(error.localizedDescription)")
๐ค Prompt for AI Agents |
||||||
| } | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
๐งน Nitpick | ๐ต Trivial
OSLog.framework ๋ช ์์ ๋งํฌ๊ฐ ๋ถํ์ํฉ๋๋ค.
OSLog๋ iOS 10๋ถํฐ ์ฌ์ฉ ๊ฐ๋ฅํ ์์คํ ํ๋ ์์ํฌ๋ก,
import OSLog๋ง์ผ๋ก ์ฌ์ฉํ ์ ์์ต๋๋ค. ํ๋ก์ ํธ์ ๋ช ์์ ์ผ๋ก ๋งํฌํ ํ์๊ฐ ์์ผ๋ฉฐ, ์ด ์ฐธ์กฐ์ ๊ด๋ จ๋ Frameworks ๊ทธ๋ฃน(lines 46-53)์ ์ ๊ฑฐํด๋ ๋ฉ๋๋ค.๐ค Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
์ง์ ๋๋ฐ..;;