@@ -58,11 +58,11 @@ type AuthConfig struct {
58
58
59
59
// ClientOptions holds optional configuration options for the HTTP Client.
60
60
type ClientOptions struct {
61
- LogLevel logger. LogLevel // Field for defining tiered logging level.
62
- HideSensitiveData bool // Field for defining whether sensitive fields should be hidden in logs.
63
- MaxRetryAttempts int // Config item defines the max number of retry request attempts for retryable HTTP methods.
64
- EnableDynamicRateLimiting bool // Field for defining whether dynamic rate limiting should be enabled.
65
- MaxConcurrentRequests int // Field for defining the maximum number of concurrent requests allowed in the semaphore
61
+ LogLevel string // Field for defining tiered logging level.
62
+ HideSensitiveData bool // Field for defining whether sensitive fields should be hidden in logs.
63
+ MaxRetryAttempts int // Config item defines the max number of retry request attempts for retryable HTTP methods.
64
+ EnableDynamicRateLimiting bool // Field for defining whether dynamic rate limiting should be enabled.
65
+ MaxConcurrentRequests int // Field for defining the maximum number of concurrent requests allowed in the semaphore
66
66
TokenRefreshBufferPeriod time.Duration
67
67
TotalRetryDuration time.Duration
68
68
CustomTimeout time.Duration
@@ -81,15 +81,14 @@ type PerformanceMetrics struct {
81
81
82
82
// BuildClient creates a new HTTP client with the provided configuration.
83
83
func BuildClient (config ClientConfig ) (* Client , error ) {
84
- // Initialize the zap logger.
85
- log := logger .BuildLogger (config .ClientOptions .LogLevel )
84
+ // Parse the log level string to logger.LogLevel
85
+ parsedLogLevel := logger .ParseLogLevelFromString (config .ClientOptions .LogLevel )
86
86
87
- // Set the logger's level based on the provided configuration.
88
- log . SetLevel ( config . ClientOptions . LogLevel )
87
+ // Initialize the logger with the parsed log level
88
+ log := logger . BuildLogger ( parsedLogLevel )
89
89
90
- if config .ClientOptions .LogLevel < logger .LogLevelDebug || config .ClientOptions .LogLevel > logger .LogLevelFatal {
91
- return nil , log .Error ("Invalid LogLevel setting" , zap .Int ("Provided LogLevel" , int (config .ClientOptions .LogLevel )))
92
- }
90
+ // Set the logger's level (optional if BuildLogger already sets the level based on the input)
91
+ log .SetLevel (parsedLogLevel )
93
92
94
93
// Use the APIType from the config to determine which API handler to load
95
94
apiHandler , err := LoadAPIHandler (config .Environment .APIType , log )
@@ -165,7 +164,7 @@ func BuildClient(config ClientConfig) (*Client, error) {
165
164
zap .String ("Instance Name" , client .InstanceName ),
166
165
zap .String ("Override Base Domain" , config .Environment .OverrideBaseDomain ),
167
166
zap .String ("Authentication Method" , authMethod ),
168
- zap .String ("Logging Level" , config .ClientOptions .LogLevel . String () ),
167
+ zap .String ("Logging Level" , config .ClientOptions .LogLevel ),
169
168
zap .Bool ("Hide Sensitive Data In Logs" , config .ClientOptions .HideSensitiveData ),
170
169
zap .Int ("Max Retry Attempts" , config .ClientOptions .MaxRetryAttempts ),
171
170
zap .Int ("Max Concurrent Requests" , config .ClientOptions .MaxConcurrentRequests ),
0 commit comments