Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
Allow Debug messages from ec2 driver to include request / response da…
Browse files Browse the repository at this point in the history
…ta sent to aws.

Signed-off-by: Jeffrey Ellin <jeff@ellin.com>
  • Loading branch information
jellin committed Jan 12, 2016
1 parent e0570c0 commit 6d41d8c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/amazonec2/amazonec2.go
Original file line number Diff line number Diff line change
Expand Up @@ -655,8 +655,11 @@ func (d *Driver) Remove() error {

func (d *Driver) getClient() *ec2.EC2 {
config := aws.NewConfig()
alogger := AwsLogger()
config = config.WithRegion(d.Region)
config = config.WithCredentials(credentials.NewStaticCredentials(d.AccessKey, d.SecretKey, d.SessionToken))
config = config.WithLogger(alogger)
config = config.WithLogLevel(aws.LogDebugWithHTTPBody)
return ec2.New(session.New(config))
}

Expand Down
21 changes: 21 additions & 0 deletions drivers/amazonec2/logger.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package amazonec2

import (
"github.com/aws/aws-sdk-go/aws"
"log"
"os"
)

type awslogger struct {
logger *log.Logger
}

func AwsLogger() aws.Logger {
return &awslogger{
logger: log.New(os.Stderr, "", log.LstdFlags),
}
}

func (l awslogger) Log(args ...interface{}) {
l.logger.Println(args...)
}

0 comments on commit 6d41d8c

Please sign in to comment.