feat: add cli switch fx-debug to disable our custom logger
This commit is contained in:
parent
57c4a1ae7d
commit
2de10a7401
|
@ -9,11 +9,14 @@ import (
|
|||
_logger "git.lumeweb.com/LumeWeb/portal/logger"
|
||||
"git.lumeweb.com/LumeWeb/portal/protocols"
|
||||
"git.lumeweb.com/LumeWeb/portal/storage"
|
||||
flag "github.com/spf13/pflag"
|
||||
"github.com/spf13/viper"
|
||||
"go.uber.org/fx"
|
||||
_"go.uber.org/fx/fxevent"
|
||||
"go.uber.org/fx/fxevent"
|
||||
_ "go.uber.org/fx/fxevent"
|
||||
"go.uber.org/zap"
|
||||
_"go.uber.org/zap/zapcore"
|
||||
"go.uber.org/zap/zapcore"
|
||||
_ "go.uber.org/zap/zapcore"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -26,9 +29,27 @@ func main() {
|
|||
logger.Fatal("Failed to load config", zap.Error(err))
|
||||
}
|
||||
|
||||
var fxDebug bool
|
||||
|
||||
flag.BoolVar(&fxDebug, "fx-debug", false, "Enable fx framework debug logging")
|
||||
flag.Parse()
|
||||
|
||||
protocols.RegisterProtocols()
|
||||
api.RegisterApis()
|
||||
|
||||
var fxLogger fx.Option
|
||||
|
||||
fxLogger = fx.WithLogger(func(logger *zap.Logger) fxevent.Logger {
|
||||
log := &fxevent.ZapLogger{Logger: logger}
|
||||
log.UseLogLevel(zapcore.InfoLevel)
|
||||
log.UseErrorLevel(zapcore.ErrorLevel)
|
||||
return log
|
||||
})
|
||||
|
||||
if fxDebug {
|
||||
fxLogger = fx.Options()
|
||||
}
|
||||
|
||||
fx.New(
|
||||
fx.Provide(_logger.NewFallbackLogger),
|
||||
fx.Provide(func() *viper.Viper {
|
||||
|
@ -37,13 +58,8 @@ func main() {
|
|||
|
||||
fx.Decorate(func() *zap.Logger {
|
||||
return logger
|
||||
}),/*
|
||||
fx.WithLogger(func(logger *zap.Logger) fxevent.Logger {
|
||||
log := &fxevent.ZapLogger{Logger: logger}
|
||||
log.UseLogLevel(zapcore.InfoLevel)
|
||||
log.UseErrorLevel(zapcore.ErrorLevel)
|
||||
return log
|
||||
}),*/
|
||||
}),
|
||||
fxLogger,
|
||||
fx.Invoke(initCheckRequiredConfig),
|
||||
fx.Provide(NewIdentity),
|
||||
db.Module,
|
||||
|
|
Loading…
Reference in New Issue