diff --git a/aws_config.go b/aws_config.go index f395146f..bd3c53b1 100644 --- a/aws_config.go +++ b/aws_config.go @@ -159,6 +159,8 @@ func commonLoadOptions(c *Config) ([]func(*config.LoadOptions) error, error) { config.WithRegion(c.Region), config.WithHTTPClient(httpClient), config.WithAPIOptions(apiOptions), + config.WithClientLogMode(aws.LogRequestWithBody | aws.LogResponseWithBody | aws.LogRetries), + config.WithLogger(debugLogger{}), } if len(c.SharedConfigFiles) > 0 { @@ -168,13 +170,6 @@ func commonLoadOptions(c *Config) ([]func(*config.LoadOptions) error, error) { ) } - if c.DebugLogging { - loadOptions = append(loadOptions, - config.WithClientLogMode(aws.LogRequestWithBody|aws.LogResponseWithBody|aws.LogRetries), - config.WithLogger(debugLogger{}), - ) - } - if c.EC2MetadataServiceEndpoint != "" { loadOptions = append(loadOptions, config.WithEC2IMDSEndpoint(c.EC2MetadataServiceEndpoint), diff --git a/aws_config_test.go b/aws_config_test.go index 96c817fe..707af08f 100644 --- a/aws_config_test.go +++ b/aws_config_test.go @@ -757,9 +757,8 @@ region = us-east-1 RoleARN: servicemocks.MockStsAssumeRoleArn, SessionName: servicemocks.MockStsAssumeRoleSessionName, }, - DebugLogging: true, - Region: "us-east-1", - SecretKey: servicemocks.MockStaticSecretKey, + Region: "us-east-1", + SecretKey: servicemocks.MockStaticSecretKey, }, Description: "assume role error", ExpectedError: func(err error) bool { @@ -2004,7 +2003,6 @@ func TestRetryHandlers(t *testing.T) { MaxRetries: maxRetries, SecretKey: servicemocks.MockStaticSecretKey, SkipCredsValidation: true, - DebugLogging: true, } awsConfig, err := GetAwsConfig(context.Background(), config) if err != nil { diff --git a/internal/config/config.go b/internal/config/config.go index c7eb7592..318d9ae7 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -8,7 +8,6 @@ type Config struct { AssumeRole *AssumeRole CallerDocumentationURL string CallerName string - DebugLogging bool EC2MetadataServiceEndpoint string EC2MetadataServiceEndpointMode string HTTPProxy string diff --git a/v2/awsv1shim/session.go b/v2/awsv1shim/session.go index a5087b6a..01ecb5f7 100644 --- a/v2/awsv1shim/session.go +++ b/v2/awsv1shim/session.go @@ -54,6 +54,8 @@ func getSessionOptions(awsC *awsv2.Config, c *awsbase.Config) (*session.Options, creds.SessionToken, ), HTTPClient: httpClient, + LogLevel: aws.LogLevel(aws.LogDebugWithHTTPBody | aws.LogDebugWithRequestRetries | aws.LogDebugWithRequestErrors), + Logger: debugLogger{}, MaxRetries: aws.Int(0), Region: aws.String(awsC.Region), UseFIPSEndpoint: convertFIPSEndpointState(useFIPSEndpoint), @@ -61,12 +63,6 @@ func getSessionOptions(awsC *awsv2.Config, c *awsbase.Config) (*session.Options, }, } - // This needs its own debug logger. Don't reuse or wrap the AWS SDK for Go v2 logger, since it hardcodes the string "aws-sdk-go-v2" - if c.DebugLogging { - options.Config.LogLevel = aws.LogLevel(aws.LogDebugWithHTTPBody | aws.LogDebugWithRequestRetries | aws.LogDebugWithRequestErrors) - options.Config.Logger = debugLogger{} - } - return options, nil } diff --git a/v2/awsv1shim/session_test.go b/v2/awsv1shim/session_test.go index 18b6f26b..e82c1f1d 100644 --- a/v2/awsv1shim/session_test.go +++ b/v2/awsv1shim/session_test.go @@ -41,7 +41,7 @@ func TestGetSessionOptions(t *testing.T) { false, }, {"ConfigWithCredsAndOptions", - &awsbase.Config{AccessKey: "MockAccessKey", SecretKey: "MockSecretKey", Insecure: true, DebugLogging: true}, + &awsbase.Config{AccessKey: "MockAccessKey", SecretKey: "MockSecretKey", Insecure: true}, false, }, } @@ -799,9 +799,8 @@ region = us-east-1 RoleARN: servicemocks.MockStsAssumeRoleArn, SessionName: servicemocks.MockStsAssumeRoleSessionName, }, - DebugLogging: true, - Region: "us-east-1", - SecretKey: servicemocks.MockStaticSecretKey, + Region: "us-east-1", + SecretKey: servicemocks.MockStaticSecretKey, }, Description: "assume role error", ExpectedError: func(err error) bool {