aws-sdk-go-v2 custom logger

Viewed 322
1 Answers

It seems that sdk v2 offers a func wrapper to satisfy logging.logger:


import (
   ...
   "github.com/aws/aws-sdk-go-v2/config"
   "github.com/aws/smithy-go/logging"
   log "github.com/sirupsen/logrus"
)

func main() {
    
    logger := logging.LoggerFunc(func(classification logging.Classification, format string, v ...interface{}) {
        // your custom logging 
        log.WithField("process", "s3").Debug(v...)
    })

    cfg, err := config.LoadDefaultConfig(
        context.TODO(),
        ...
        config.WithLogger(logger),
    )
    ....
}
Related