import Constants import Dependencies import Foundation import ShellClient public struct LoggingOptions: Equatable, Sendable { public let commandName: String public let logLevel: Logger.Level public init(commandName: String, logLevel: Logger.Level) { self.commandName = commandName self.logLevel = logLevel } @discardableResult public func withLogger( operation: @Sendable @escaping () async throws -> T ) async rethrows -> T { try await withDependencies { $0.logger = .init(label: "\(Constants.executableName)") $0.logger.logLevel = logLevel $0.logger[metadataKey: "command"] = "\(commandName.blue)" } operation: { try await operation() } } }