本文整理汇总了Golang中github.com/aws/aws-sdk-go/aws.LogLevel函数的典型用法代码示例。如果您正苦于以下问题:Golang LogLevel函数的具体用法?Golang LogLevel怎么用?Golang LogLevel使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LogLevel函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: getConfig
func getConfig(c *cli.Context) *aws.Config {
debug := c.Bool("debug")
profile := c.String("profile")
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 &config
}
开发者ID:barnybug,项目名称:cli53,代码行数:14,代码来源:util.go
示例17: doAction
func doAction(c *cli.Context) {
awsKeyID := c.String("aws-key-id")
awsSecKey := c.String("aws-secret-key")
mackerelAPIKey := c.String("mackerel-api-key")
client := mkr.NewClient(mackerelAPIKey)
sess := session.New(&aws.Config{
Credentials: credentials.NewStaticCredentials(awsKeyID, awsSecKey, ""),
Region: aws.String("ap-northeast-1"),
})
awsSession := NewAWSSession(sess)
if c.Bool("debug") {
sess.Config.LogLevel = aws.LogLevel(aws.LogDebug)
}
rdss := awsSession.fetchRDSList()
awsSession.updateAWSElementList(rdss, client)
elbs := awsSession.fetchLoadBalancerList()
awsSession.updateAWSElementList(elbs, client)
tickChan := time.NewTicker(60 * time.Second)
quit := make(chan struct{})
awsSession.crawlRDSMetrics(client, rdss)
for {
select {
case <-tickChan.C:
awsSession.crawlELBMetrics(client, elbs)
awsSession.crawlRDSMetrics(client, rdss)
case <-quit:
tickChan.Stop()
return
}
}
//listMetric(sess)
}
开发者ID:mackerelio,项目名称:mackerel-crawler,代码行数:41,代码来源:main.go
示例18: New
// New makes an instance of StorageS3 storage driver
func New(client *docker.Client, cacheRoot string) *StorageS3 {
retryer := NewRetryer(400, 6)
// TODO: configure region?
cfg := &aws.Config{
Region: aws.String("us-east-1"),
Retryer: retryer,
Logger: &Logger{},
}
if log.StandardLogger().Level >= log.DebugLevel {
cfg.LogLevel = aws.LogLevel(aws.LogDebugWithRequestErrors)
}
return &StorageS3{
client: client,
cacheRoot: cacheRoot,
s3: s3.New(session.New(), cfg),
retryer: retryer,
}
}
开发者ID:grammarly,项目名称:rocker-compose,代码行数:22,代码来源:s3.go
示例19: 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.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
// use a shorter timeout than default because the metadata
// service is local if it is running, and to fail faster
// if not running on an ec2 instance.
Timeout: 5 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
},
}
}
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:skion,项目名称:amazon-ecs-cli,代码行数:40,代码来源:service.go
示例20: SetUpSuite
func (s *GoofysTest) SetUpSuite(t *C) {
//addr := "play.minio.io:9000"
const LOCAL_TEST = true
if LOCAL_TEST {
addr := "127.0.0.1:8080"
err := s.waitFor(t, addr)
t.Assert(err, IsNil)
s.awsConfig = &aws.Config{
//Credentials: credentials.AnonymousCredentials,
Credentials: credentials.NewStaticCredentials("foo", "bar", ""),
Region: aws.String("us-west-2"),
Endpoint: aws.String(addr),
DisableSSL: aws.Bool(true),
S3ForcePathStyle: aws.Bool(true),
MaxRetries: aws.Int(0),
//Logger: t,
//LogLevel: aws.LogLevel(aws.LogDebug),
//LogLevel: aws.LogLevel(aws.LogDebug | aws.LogDebugWithHTTPBody),
}
} else {
s.awsConfig = &aws.Config{
Region: aws.String("us-west-2"),
DisableSSL: aws.Bool(true),
LogLevel: aws.LogLevel(aws.LogDebug | aws.LogDebugWithSigning),
S3ForcePathStyle: aws.Bool(true),
}
}
s.sess = session.New(s.awsConfig)
s.s3 = s3.New(s.sess)
s.s3.Handlers.Sign.Clear()
s.s3.Handlers.Sign.PushBack(SignV2)
s.s3.Handlers.Sign.PushBackNamed(corehandlers.BuildContentLengthHandler)
_, err := s.s3.ListBuckets(nil)
t.Assert(err, IsNil)
}
开发者ID:x5u,项目名称:goofys,代码行数:38,代码来源:goofys_test.go
注:本文中的github.com/aws/aws-sdk-go/aws.LogLevel函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论