func (c *DeleteConfig) logRequestError(rt arn.ResourceType, rn interface{}, err error, extraFields ...logrus.Fields) {
	fields := logrus.Fields{
		"error":         err,
		"resource_type": rt,
		"resource_name": rn,
	}
	if aerr, ok := err.(awserr.Error); ok {
		fields["aws_err_code"] = aerr.Code()
		fields["aws_err_msg"] = aerr.Message()
	} else {
		fields["err_msg"] = err.Error()
	}
	for _, ef := range extraFields {
		for fk, fv := range ef {
			fields[fk] = fv
		}
	}
	failMsg := fmt.Sprintf("Failed to delete %s \"%v\"", rt, rn)
	if fields["parent_resource_type"] != nil && fields["parent_resource_name"] != nil {
		failMsg += fmt.Sprintf(" from %s \"%s\"", fields["parent_resource_type"], fields["parent_resource_name"])
	}
	fmt.Printf("%s: %s\n", failMsg, err.Error())
	c.Logger.WithFields(fields).Info("Resource request failed.")
}
Log errors to a DeleteConfig.Logger
package deleter
import (
	"encoding/json"
	"fmt"
	"io"
	"github.com/aws/aws-sdk-go/aws"
	"github.com/aws/aws-sdk-go/aws/awserr"
	"github.com/aws/aws-sdk-go/aws/session"
	"github.com/coreos/grafiti/arn"
	"github.com/coreos/grafiti/deleter/retryer"
	"github.com/sirupsen/logrus"
	"github.com/spf13/viper"
)
const drStr = "(dry-run)"
const ErrCodeValidationError = "ValidationError"
func setUpAWSSession() *session.Session {
	maxRetries := viper.GetInt("maxNumRequestRetries")
	return session.Must(session.NewSession(
		&aws.Config{
			Retryer: retryer.DeleteRetryer{NumMaxRetries: maxRetries},
		},
	))
}
func CalcChunk(curr, size, chunk int) int {
	if curr+chunk > size {
		return size
	}
	return curr + chunk
}
type DeleteConfig struct {
	DryRun       bool
	IgnoreErrors bool
	Logger       logrus.FieldLogger
}
type LogEntry struct {
	Error              error            `json:"error"`
	ResourceType       arn.ResourceType `json:"resource_type"`
	ResourceName       arn.ResourceName `json:"resource_name"`
	AWSErrorCode       string           `json:"aws_err_code,omitempty"`
	AWSErrorMsg        string           `json:"aws_err_msg,omitempty"`
	ErrMsg             string           `json:"err_msg,omitempty"`
	ParentResourceType arn.ResourceType `json:"parent_resource_type,omitempty"`
	ParentResourceName arn.ResourceName `json:"parent_resource_name,omitempty"`
}