Skip to content

Commit

Permalink
fix logger cli
Browse files Browse the repository at this point in the history
  • Loading branch information
ocnc2 committed Aug 25, 2024
1 parent c5184c9 commit 44b6a86
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 52 deletions.
1 change: 0 additions & 1 deletion beacond/cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func run() error {
clicomponents.DefaultClientComponents(),
// TODO: remove these, and eventually pull cfg and chainspec
// from built node
nodecomponents.ProvideConfig,
nodecomponents.ProvideChainSpec,
),
),
Expand Down
3 changes: 2 additions & 1 deletion mod/cli/pkg/components/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (

type LoggerInput struct {
depinject.In

Out io.Writer
}

Expand All @@ -39,6 +38,8 @@ type LoggerInput struct {
func ProvideLogger(
in LoggerInput,
) *phuslu.Logger {
// the logger config should be passed in here, but it is not yet populated
// so we pass in nil for now to get the default logger.
logger := phuslu.NewLogger(in.Out, nil)
logger.AddKeyColor("error", log.Red)
logger.AddKeyColor("err", log.Red)
Expand Down
16 changes: 9 additions & 7 deletions mod/node-core/pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"cosmossdk.io/depinject"
sdklog "cosmossdk.io/log"
servertypes "github.com/berachain/beacon-kit/mod/cli/pkg/commands/server/types"
"github.com/berachain/beacon-kit/mod/config"
cometbft "github.com/berachain/beacon-kit/mod/consensus/pkg/cometbft/service"
"github.com/berachain/beacon-kit/mod/log"
"github.com/berachain/beacon-kit/mod/node-core/pkg/types"
Expand Down Expand Up @@ -72,7 +73,7 @@ func New[
// build a new instance of the node.
// It is necessary to adhere to the types.AppCreator[T] interface.
func (nb *NodeBuilder[NodeT, LoggerT, LoggerConfigT]) Build(
logger sdklog.Logger,
sdklogger sdklog.Logger,
db dbm.DB,
_ io.Writer,
cmtCfg *cmtcfg.Config,
Expand All @@ -85,6 +86,8 @@ func (nb *NodeBuilder[NodeT, LoggerT, LoggerConfigT]) Build(
}
beaconNode NodeT
cmtService *cometbft.Service
config *config.Config
logger = sdklogger.Impl().(LoggerT)
)

// build all node components using depinject
Expand All @@ -95,21 +98,20 @@ func (nb *NodeBuilder[NodeT, LoggerT, LoggerConfigT]) Build(
),
depinject.Supply(
appOpts,
logger.Impl().(LoggerT),
logger,
db,
cmtCfg,
),
// TODO: cosmos depinject bad project, fixed with dig.
// depinject.Invoke(
// SetLoggerConfig[LoggerT, LoggerConfigT],
// ),
),
&beaconNode,
&apiBackend,
&beaconNode,
&cmtService,
&config,
); err != nil {
panic(err)
}
// attach the logger config
logger.WithConfig(any(config.GetLogger()).(LoggerConfigT))

if apiBackend == nil {
panic("node or api backend is nil")
Expand Down
43 changes: 0 additions & 43 deletions mod/node-core/pkg/builder/invokers.go

This file was deleted.

0 comments on commit 44b6a86

Please sign in to comment.