Created
April 16, 2024 19:21
-
-
Save Shubham0812/4fb93e0876f98fea00049d398c4cd2cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import OSLog | |
enum LogType { | |
case info | |
case notice | |
case warning | |
case fault | |
// case debug | |
// case error | |
// case fault | |
// case trace | |
} | |
enum LoggerCategory: String { | |
case viewController | |
case network | |
case viewModel | |
} | |
struct OSLogger { | |
// MARK: - Variables | |
private static let subsystem = Bundle.main.bundleIdentifier! | |
// MARK: - Functions | |
static func log(type: LogType, category: LoggerCategory, message: String) { | |
let logger = Logger(subsystem: subsystem, category: category .rawValue.capitalized) | |
switch type { | |
case .info: | |
logger.info("\(message)") | |
case .notice: | |
logger.notice("\(message)") | |
case .warning: | |
logger.warning("\(message)") | |
case .fault: | |
logger.fault("\(message)") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment