コード例 #1
0
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,
	}
}
コード例 #2
0
func init() {
	level = logLevel(math.Min(float64(trace), math.Max(float64(fatal), float64(config.NewConfig().LogLevel))))

	handle := ioutil.Discard
	if level >= fatal {
		handle = os.Stderr
	}
	Fatal = log.New(handle, "FATAL: ", log.Ldate|log.Ltime|log.Lshortfile)

	handle = ioutil.Discard
	if level >= err {
		handle = os.Stderr
	}
	Error = log.New(handle, "ERROR: ", log.Ldate|log.Ltime|log.Lshortfile)

	handle = ioutil.Discard
	if level >= warn {
		handle = os.Stdout
	}
	Warn = log.New(handle, "WARNING: ", log.Ldate|log.Ltime|log.Lshortfile)

	handle = ioutil.Discard
	if level >= info {
		handle = os.Stdout
	}
	Info = log.New(handle, "INFO: ", log.Ldate|log.Ltime|log.Lshortfile)

	handle = ioutil.Discard
	if level >= debug {
		handle = os.Stdout
	}
	Debug = log.New(handle, "DEBUG: ", log.Ldate|log.Ltime|log.Lshortfile)

	handle = ioutil.Discard
	if level >= trace {
		handle = os.Stdout
	}
	Trace = log.New(handle, "TRACE: ", log.Ldate|log.Ltime|log.Lshortfile)
}
コード例 #3
0
ファイル: main.go プロジェクト: pottava/golang-microservices
func main() {
	cfg := config.NewConfig()
	logs.Debug.Print("[config] " + cfg.String())
	logs.Info.Printf("[service] listening on port %v", cfg.Port)
	logs.Fatal.Print(http.ListenAndServe(":"+fmt.Sprint(cfg.Port), nil))
}
コード例 #4
0
ファイル: http.go プロジェクト: pottava/golang-microservices
func init() {
	cfg = config.NewConfig()
}