2019-11-06 12:33:46 +00:00
|
|
|
package main
|
|
|
|
|
2020-11-09 13:43:23 +00:00
|
|
|
import (
|
2021-01-14 10:28:20 +00:00
|
|
|
"github.com/nspcc-dev/cdn-sdk/logger"
|
2021-03-25 08:27:59 +00:00
|
|
|
"github.com/nspcc-dev/neofs-http-gate/global"
|
2020-11-09 13:43:23 +00:00
|
|
|
"github.com/spf13/viper"
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
|
|
|
func newLogger(v *viper.Viper) *zap.Logger {
|
|
|
|
options := []logger.Option{
|
2020-11-27 15:18:53 +00:00
|
|
|
logger.WithLevel(v.GetString(cfgLoggerLevel)),
|
|
|
|
logger.WithTraceLevel(v.GetString(cfgLoggerTraceLevel)),
|
2020-11-09 13:43:23 +00:00
|
|
|
|
2020-11-27 15:18:53 +00:00
|
|
|
logger.WithFormat(v.GetString(cfgLoggerFormat)),
|
2020-11-09 13:43:23 +00:00
|
|
|
|
2020-11-27 15:18:53 +00:00
|
|
|
logger.WithSamplingInitial(v.GetInt(cfgLoggerSamplingInitial)),
|
|
|
|
logger.WithSamplingThereafter(v.GetInt(cfgLoggerSamplingThereafter)),
|
2020-11-09 13:43:23 +00:00
|
|
|
|
2020-11-27 15:18:53 +00:00
|
|
|
logger.WithAppName(v.GetString(cfgApplicationName)),
|
|
|
|
logger.WithAppVersion(v.GetString(cfgApplicationVersion)),
|
2020-11-09 13:43:23 +00:00
|
|
|
}
|
|
|
|
|
2020-11-27 15:18:53 +00:00
|
|
|
if v.GetBool(cfgLoggerNoCaller) {
|
2020-11-09 13:43:23 +00:00
|
|
|
options = append(options, logger.WithoutCaller())
|
|
|
|
}
|
|
|
|
|
2020-11-27 15:18:53 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2019-11-06 12:33:46 +00:00
|
|
|
func main() {
|
|
|
|
var (
|
2019-12-21 10:26:14 +00:00
|
|
|
v = settings()
|
|
|
|
l = newLogger(v)
|
2021-03-25 08:27:59 +00:00
|
|
|
g = global.Context()
|
|
|
|
a = newApp(g, WithLogger(l), WithConfig(v))
|
2020-03-31 08:37:10 +00:00
|
|
|
)
|
|
|
|
go a.Serve(g)
|
|
|
|
go a.Worker(g)
|
|
|
|
a.Wait()
|
2019-11-06 12:33:46 +00:00
|
|
|
}
|