當前位置: 首頁>>代碼示例>>Golang>>正文


Golang aws.LogLevel函數代碼示例

本文整理匯總了Golang中github.com/aws/aws-sdk-go/aws.LogLevel函數的典型用法代碼示例。如果您正苦於以下問題:Golang LogLevel函數的具體用法?Golang LogLevel怎麽用?Golang LogLevel使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了LogLevel函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: init

func init() {
	if os.Getenv("DEBUG") != "" {
		aws.DefaultConfig.LogLevel = aws.LogLevel(aws.LogDebug)
	}
	if os.Getenv("DEBUG_SIGNING") != "" {
		aws.DefaultConfig.LogLevel = aws.LogLevel(aws.LogDebugWithSigning)
	}
	if os.Getenv("DEBUG_BODY") != "" {
		aws.DefaultConfig.LogLevel = aws.LogLevel(aws.LogDebugWithSigning | aws.LogDebugWithHTTPBody)
	}

	if aws.StringValue(aws.DefaultConfig.Region) == "" {
		panic("AWS_REGION must be configured to run integration tests")
	}
}
開發者ID:Talos208,項目名稱:aws-sdk-go,代碼行數:15,代碼來源:integration.go

示例2: copyConfig

func copyConfig(config *Config) *aws.Config {
	if config == nil {
		config = &Config{}
	}
	c := &aws.Config{
		Credentials: credentials.AnonymousCredentials,
		Endpoint:    config.Endpoint,
		HTTPClient:  config.HTTPClient,
		Logger:      config.Logger,
		LogLevel:    config.LogLevel,
		MaxRetries:  config.MaxRetries,
	}

	if c.HTTPClient == nil {
		c.HTTPClient = http.DefaultClient
	}
	if c.Logger == nil {
		c.Logger = aws.NewDefaultLogger()
	}
	if c.LogLevel == nil {
		c.LogLevel = aws.LogLevel(aws.LogOff)
	}
	if c.MaxRetries == nil {
		c.MaxRetries = aws.Int(DefaultRetries)
	}

	return c
}
開發者ID:ManifoldMike,項目名稱:coreos-kubernetes,代碼行數:28,代碼來源:service.go

示例3: config

func config() *aws.Config {
	log := aws.LogLevel(aws.LogOff)
	cfg := app.NewConfig()
	if cfg.AwsLog {
		log = aws.LogLevel(aws.LogDebug)
	}
	return &aws.Config{
		Credentials: credentials.NewChainCredentials(
			[]credentials.Provider{
				&credentials.EnvProvider{},
				&ec2rolecreds.EC2RoleProvider{ExpiryWindow: cfg.AwsRoleExpiry * time.Minute},
			}),
		Region:   aws.String(os.Getenv("AWS_REGION")),
		LogLevel: log,
	}
}
開發者ID:pottava,項目名稱:golang-microservices,代碼行數:16,代碼來源:config.go

示例4: GetFile

func GetFile(region, bucketName, path, keyId, secretKey, token string) (io.ReadCloser, int64, error) {
	creds := credentials.NewStaticCredentials(keyId, secretKey, token)

	if _, err := creds.Get(); err != nil {
		return nil, 0, err
	}

	awsconfig := &aws.Config{
		Region:           aws.String(region),
		Endpoint:         aws.String("s3.amazonaws.com"),
		S3ForcePathStyle: aws.Bool(true),
		Credentials:      creds,
		LogLevel:         aws.LogLevel(0),
	}

	sess := session.New(awsconfig)
	svc := s3.New(sess)

	params := &s3.GetObjectInput{
		Bucket: aws.String(bucketName),
		Key:    aws.String(path),
	}

	resp, err := svc.GetObject(params)
	if err != nil {
		return nil, 0, err
	}

	// log.Println(resp)
	return resp.Body, *resp.ContentLength, nil
}
開發者ID:sarosamurai,項目名稱:awssrv,代碼行數:31,代碼來源:awssrv.go

示例5: NewSessionWithLevel

// NewSessionWithLevel returns an AWS Session (https://github.com/aws/aws-sdk-go/wiki/Getting-Started-Configuration)
// object that attaches a debug level handler to all AWS requests from services
// sharing the session value.
func NewSessionWithLevel(level aws.LogLevelType, logger *logrus.Logger) *session.Session {
	awsConfig := &aws.Config{
		CredentialsChainVerboseErrors: aws.Bool(true),
	}
	// Log AWS calls if needed
	switch logger.Level {
	case logrus.DebugLevel:
		awsConfig.LogLevel = aws.LogLevel(level)
	}
	awsConfig.Logger = &logrusProxy{logger}
	sess := session.New(awsConfig)
	sess.Handlers.Send.PushFront(func(r *request.Request) {
		logger.WithFields(logrus.Fields{
			"Service":   r.ClientInfo.ServiceName,
			"Operation": r.Operation.Name,
			"Method":    r.Operation.HTTPMethod,
			"Path":      r.Operation.HTTPPath,
			"Payload":   r.Params,
		}).Debug("AWS Request")
	})

	logger.WithFields(logrus.Fields{
		"Name":    aws.SDKName,
		"Version": aws.SDKVersion,
	}).Debug("AWS SDK Info")

	return sess
}
開發者ID:mweagle,項目名稱:Sparta,代碼行數:31,代碼來源:session.go

示例6: New

func New(debug bool) MetadataFetcher {
	sess := session.New()
	if debug {
		sess.Config.LogLevel = aws.LogLevel(aws.LogDebug)
	}
	return ec2metadata.New(sess)
}
開發者ID:venkat434,項目名稱:AWSnycast,代碼行數:7,代碼來源:instancemetadata.go

示例7: New

func New(debug bool) MetadataFetcher {
	c := ec2metadata.Config{}
	if debug {
		c.LogLevel = aws.LogLevel(aws.LogDebug)
	}
	return ec2metadata.New(&c)
}
開發者ID:daichenge,項目名稱:AWSnycast,代碼行數:7,代碼來源:instancemetadata.go

示例8: TestMain

func TestMain(m *testing.M) {
	flag.Parse()
	if !*integration {
		fmt.Fprintln(os.Stderr, "Skipping integration tests")
		os.Exit(0)
	}
	cfg = &aws.Config{
		Region:      aws.String("us-west-2"),
		Endpoint:    aws.String("http://localhost:8000"),
		Credentials: credentials.NewSharedCredentials("", *awsprofile),
	}
	sess = session.New(cfg)
	if *dynamodebug {
		sess.Config.LogLevel = aws.LogLevel(aws.LogDebug)
	}

	if err := loadUserFixtures(sess); err != nil {
		fmt.Fprintf(os.Stderr, "Error loading 'user' integration fixtures: %s", err)
		os.Exit(1)
	}
	if err := loadPostFixtures(sess); err != nil {
		fmt.Fprintf(os.Stderr, "Error loading 'post' integration fixtures: %s", err)
		os.Exit(1)
	}
	os.Exit(m.Run())
}
開發者ID:blang,項目名稱:posty,代碼行數:26,代碼來源:model_integration_test.go

示例9: roleHandler

func (app *App) roleHandler(w http.ResponseWriter, r *http.Request) {
	svc := sts.New(session.New(), &aws.Config{LogLevel: aws.LogLevel(2)})
	resp, err := svc.AssumeRole(&sts.AssumeRoleInput{
		RoleArn:         aws.String(app.RoleArn),
		RoleSessionName: aws.String("aws-mock-metadata"),
	})
	if err != nil {
		log.Errorf("Error assuming role %+v", err)
		http.Error(w, err.Error(), 500)
		return
	}
	log.Debugf("STS response %+v", resp)
	credentials := Credentials{
		AccessKeyID:     *resp.Credentials.AccessKeyId,
		Code:            "Success",
		Expiration:      resp.Credentials.Expiration.Format("2006-01-02T15:04:05Z"),
		LastUpdated:     time.Now().Format("2006-01-02T15:04:05Z"),
		SecretAccessKey: *resp.Credentials.SecretAccessKey,
		Token:           *resp.Credentials.SessionToken,
		Type:            "AWS-HMAC",
	}
	if err := json.NewEncoder(w).Encode(credentials); err != nil {
		log.Errorf("Error sending json %+v", err)
		http.Error(w, err.Error(), 500)
	}
}
開發者ID:jtblin,項目名稱:aws-mock-metadata,代碼行數:26,代碼來源:server.go

示例10: getStorageClient

func (gs GlacierStorage) getStorageClient() *glacier.Glacier {
	creds := credentials.NewStaticCredentials(gs.aws_access_key_id, gs.aws_secret_access_key, "")

	return glacier.New(&aws.Config{
		Region:      aws.String(gs.region),
		Credentials: creds,
		LogLevel:    aws.LogLevel(1),
	})
}
開發者ID:n-boy,項目名稱:backuper,代碼行數:9,代碼來源:toglacier.go

示例11: getService

func getService(debug bool) *route53.Route53 {
	config := aws.Config{}
	// ensures throttled requests are retried
	config.MaxRetries = aws.Int(100)
	if debug {
		config.LogLevel = aws.LogLevel(aws.LogDebug)
	}
	return route53.New(&config)
}
開發者ID:rodmur,項目名稱:cli53,代碼行數:9,代碼來源:util.go

示例12: GetECRAuth

// GetECRAuth requests AWS ECR API to get docker.AuthConfiguration token
func GetECRAuth(registry, region string) (result docker.AuthConfiguration, err error) {
	_ecrAuthCache.mu.Lock()
	defer _ecrAuthCache.mu.Unlock()

	if token, ok := _ecrAuthCache.tokens[registry]; ok {
		return token, nil
	}

	defer func() {
		_ecrAuthCache.tokens[registry] = result
	}()

	cfg := &aws.Config{
		Region: aws.String(region),
	}

	if log.StandardLogger().Level >= log.DebugLevel {
		cfg.LogLevel = aws.LogLevel(aws.LogDebugWithRequestErrors)
	}

	split := strings.Split(registry, ".")

	svc := ecr.New(session.New(), cfg)
	params := &ecr.GetAuthorizationTokenInput{
		RegistryIds: []*string{aws.String(split[0])},
	}

	res, err := svc.GetAuthorizationToken(params)
	if err != nil {
		return result, err
	}

	if len(res.AuthorizationData) == 0 {
		return result, nil
	}

	data, err := base64.StdEncoding.DecodeString(*res.AuthorizationData[0].AuthorizationToken)
	if err != nil {
		return result, err
	}

	userpass := strings.Split(string(data), ":")
	if len(userpass) != 2 {
		return result, fmt.Errorf("Cannot parse token got from ECR: %s", string(data))
	}

	result = docker.AuthConfiguration{
		Username:      userpass[0],
		Password:      userpass[1],
		ServerAddress: *res.AuthorizationData[0].ProxyEndpoint,
	}

	return
}
開發者ID:grammarly,項目名稱:rocker-compose,代碼行數:55,代碼來源:auth.go

示例13: NewGoofys

func NewGoofys(bucket string, awsConfig *aws.Config, flags *FlagStorage) *Goofys {
	// Set up the basic struct.
	fs := &Goofys{
		bucket: bucket,
		flags:  flags,
		umask:  0122,
	}

	if flags.DebugS3 {
		awsConfig.LogLevel = aws.LogLevel(aws.LogDebug | aws.LogDebugWithRequestErrors)
		s3Log.Level = logrus.DebugLevel
	}

	fs.awsConfig = awsConfig
	fs.sess = session.New(awsConfig)
	fs.s3 = fs.newS3()

	err := fs.detectBucketLocation()
	if err != nil {
		return nil
	}

	now := time.Now()
	fs.rootAttrs = fuseops.InodeAttributes{
		Size:   4096,
		Nlink:  2,
		Mode:   flags.DirMode | os.ModeDir,
		Atime:  now,
		Mtime:  now,
		Ctime:  now,
		Crtime: now,
		Uid:    fs.flags.Uid,
		Gid:    fs.flags.Gid,
	}

	fs.bufferPool = BufferPool{}.Init()

	fs.nextInodeID = fuseops.RootInodeID + 1
	fs.inodes = make(map[fuseops.InodeID]*Inode)
	root := NewInode(aws.String(""), aws.String(""), flags)
	root.Id = fuseops.RootInodeID
	root.Attributes = &fs.rootAttrs

	fs.inodes[fuseops.RootInodeID] = root
	fs.inodesCache = make(map[string]*Inode)

	fs.nextHandleID = 1
	fs.dirHandles = make(map[fuseops.HandleID]*DirHandle)

	fs.fileHandles = make(map[fuseops.HandleID]*FileHandle)

	return fs
}
開發者ID:x5u,項目名稱:goofys,代碼行數:53,代碼來源:goofys.go

示例14: getService

func getService(debug bool, profile string) *route53.Route53 {
	config := aws.Config{}
	if profile != "" {
		config.Credentials = credentials.NewSharedCredentials("", profile)
	}
	// ensures throttled requests are retried
	config.MaxRetries = aws.Int(100)
	if debug {
		config.LogLevel = aws.LogLevel(aws.LogDebug)
	}
	return route53.New(session.New(), &config)
}
開發者ID:TheBigBear,項目名稱:cli53,代碼行數:12,代碼來源:util.go

示例15: getAWSConfig

func getAWSConfig(region string, debug bool) *aws.Config {
	if debug {
		logging.SetLogging("DEBUG")
		return &aws.Config{
			Region:   aws.String(region),
			LogLevel: aws.LogLevel(aws.LogDebugWithHTTPBody),
		}
	}
	logging.SetLogging("INFO")
	return &aws.Config{
		Region: aws.String(region),
	}
}
開發者ID:nlamirault,項目名稱:aneto,代碼行數:13,代碼來源:commons.go


注:本文中的github.com/aws/aws-sdk-go/aws.LogLevel函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。