frostfs-http-gw/main.go
Evgeniy Kulikov c30b264beb
Migrate to SDK 0.3.0
- update dependencies
  - github.com/fasthttp/router v1.3.5
  - github.com/nspcc-dev/cdn-sdk v0.3.0
  - github.com/nspcc-dev/neofs-api-go v1.22.0
  - github.com/prometheus/client_golang v1.9.0
  - github.com/valyala/fasthttp v1.19.0
  - google.golang.org/grpc v1.35.0

Signed-off-by: Evgeniy Kulikov <kim@nspcc.ru>
2021-01-14 13:31:40 +03:00

55 lines
1.1 KiB
Go

package main
import (
"github.com/nspcc-dev/cdn-sdk/grace"
"github.com/nspcc-dev/cdn-sdk/logger"
"github.com/spf13/viper"
"go.uber.org/zap"
)
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)),
}
if v.GetBool(cfgLoggerNoCaller) {
options = append(options, logger.WithoutCaller())
}
if v.GetBool(cfgLoggerNoDisclaimer) {
options = append(options, logger.WithoutDisclaimer())
}
l, err := logger.New(options...)
if err != nil {
panic(err)
}
return l
}
func main() {
var (
v = settings()
l = newLogger(v)
g = grace.Context(l)
a = newApp(g,
WithLogger(l),
WithConfig(v))
)
go a.Serve(g)
go a.Worker(g)
a.Wait()
}