frostfs-http-gw/main.go

44 lines
1.1 KiB
Go
Raw Normal View History

2019-11-06 12:33:46 +00:00
package main
2020-11-09 13:43:23 +00:00
import (
"github.com/nspcc-dev/neofs-http-gate/global"
"github.com/nspcc-dev/neofs-http-gate/logger"
2020-11-09 13:43:23 +00:00
"github.com/spf13/viper"
"go.uber.org/zap"
)
func main() {
var (
v = settings()
l = newLogger(v)
)
globalContext := global.Context()
app := newApp(globalContext, WithLogger(l), WithConfig(v))
go app.Serve(globalContext)
go app.Worker(globalContext)
app.Wait()
}
2020-11-09 13:43:23 +00:00
func newLogger(v *viper.Viper) *zap.Logger {
options := []logger.Option{
logger.WithLevel(v.GetString(cfgLoggerLevel)),
logger.WithTraceLevel(v.GetString(cfgLoggerTraceLevel)),
logger.WithFormat(v.GetString(cfgLoggerFormat)),
logger.WithSamplingInitial(v.GetInt(cfgLoggerSamplingInitial)),
logger.WithSamplingThereafter(v.GetInt(cfgLoggerSamplingThereafter)),
logger.WithAppName(v.GetString(cfgApplicationName)),
logger.WithAppVersion(v.GetString(cfgApplicationVersion)),
2020-11-09 13:43:23 +00:00
}
if v.GetBool(cfgLoggerNoCaller) {
2020-11-09 13:43:23 +00:00
options = append(options, logger.WithoutCaller())
}
if v.GetBool(cfgLoggerNoDisclaimer) {
2020-11-09 13:43:23 +00:00
options = append(options, logger.WithoutDisclaimer())
}
l, err := logger.New(options...)
if err != nil {
panic(err)
}
return l
}