Skip to content

Commit 23b5213

Browse files
authored
Merge pull request #75 from deploymenttheory/dev
Dev
2 parents 505bb39 + b158917 commit 23b5213

File tree

3 files changed

+11
-154
lines changed

3 files changed

+11
-154
lines changed

httpclient/httpclient_client.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ type AuthConfig struct {
6060
type ClientOptions struct {
6161
LogLevel string // Field for defining tiered logging level.
6262
LogOutputFormat string // Field for defining the output format of the logs. Use "JSON" for JSON format, "console" for human-readable format
63+
LogConsoleSeparator string // Field for defining the separator in console output format.
6364
HideSensitiveData bool // Field for defining whether sensitive fields should be hidden in logs.
6465
MaxRetryAttempts int // Config item defines the max number of retry request attempts for retryable HTTP methods.
6566
EnableDynamicRateLimiting bool // Field for defining whether dynamic rate limiting should be enabled.
@@ -85,8 +86,13 @@ func BuildClient(config ClientConfig) (*Client, error) {
8586
// Parse the log level string to logger.LogLevel
8687
parsedLogLevel := logger.ParseLogLevelFromString(config.ClientOptions.LogLevel)
8788

88-
// Initialize the logger with the parsed log level and log output format
89-
log := logger.BuildLogger(parsedLogLevel, config.ClientOptions.LogOutputFormat)
89+
// Set default value if none is provided
90+
if config.ClientOptions.LogConsoleSeparator == "" {
91+
config.ClientOptions.LogConsoleSeparator = ","
92+
}
93+
94+
// Initialize the logger with parsed config values
95+
log := logger.BuildLogger(parsedLogLevel, config.ClientOptions.LogOutputFormat, config.ClientOptions.LogConsoleSeparator)
9096

9197
// Set the logger's level (optional if BuildLogger already sets the level based on the input)
9298
log.SetLevel(parsedLogLevel)
@@ -167,6 +173,7 @@ func BuildClient(config ClientConfig) (*Client, error) {
167173
zap.String("Authentication Method", authMethod),
168174
zap.String("Logging Level", config.ClientOptions.LogLevel),
169175
zap.String("Log Encoding Format", config.ClientOptions.LogOutputFormat),
176+
zap.String("Log Separator", config.ClientOptions.LogConsoleSeparator),
170177
zap.Bool("Hide Sensitive Data In Logs", config.ClientOptions.HideSensitiveData),
171178
zap.Int("Max Retry Attempts", config.ClientOptions.MaxRetryAttempts),
172179
zap.Int("Max Concurrent Requests", config.ClientOptions.MaxConcurrentRequests),

httpclient/httpclient_request_test.go

Lines changed: 0 additions & 147 deletions
This file was deleted.

logger/zaplogger_config.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
// BuildLogger creates and returns a new zap logger instance.
1212
// It configures the logger with JSON formatting and a custom encoder to ensure the 'pid', 'application', and 'timestamp' fields
1313
// appear at the end of each log message. The function panics if the logger cannot be initialized.
14-
func BuildLogger(logLevel LogLevel, encoding string) Logger {
14+
func BuildLogger(logLevel LogLevel, encoding string, logConsoleSeparator string) Logger {
1515

1616
// Set up custom encoder configuration
1717
encoderCfg := zap.NewProductionEncoderConfig()
@@ -39,11 +39,8 @@ func BuildLogger(logLevel LogLevel, encoding string) Logger {
3939
// Name and function encoding (optional, depends on logging requirements)
4040
encoderCfg.EncodeName = zapcore.FullNameEncoder // Encodes the logger's name as-is, without any modifications.
4141

42-
// Configure encoding for complex types and custom objects (optional, advanced usage)
43-
// encoderCfg.NewReflectedEncoder = customReflectedEncoder // Custom function to encode objects that don't have native or custom marshalers.
44-
4542
// Console-specific settings (if using console encoding)
46-
encoderCfg.ConsoleSeparator = "\t" // Separator character used in console encoding.
43+
encoderCfg.ConsoleSeparator = logConsoleSeparator // Separator character used in console encoding.
4744

4845
// Convert the custom LogLevel to zap's logging level
4946
zapLogLevel := convertToZapLevel(logLevel)

0 commit comments

Comments
 (0)