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