From 940bf159e17ef04ea5b998841fd9adfda1c84223 Mon Sep 17 00:00:00 2001 From: Peter Rabbitson Date: Sat, 27 Jul 2024 08:55:40 +0200 Subject: [PATCH] chore: logging: switch runtime Print() spots to use the logger --- chain/consensus/filcns/upgrades.go | 6 +----- node/bundle/bundle.go | 6 ++++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/chain/consensus/filcns/upgrades.go b/chain/consensus/filcns/upgrades.go index 3450fee1b76..c936875d2c7 100644 --- a/chain/consensus/filcns/upgrades.go +++ b/chain/consensus/filcns/upgrades.go @@ -4,7 +4,6 @@ import ( "bytes" "context" _ "embed" - "fmt" "os" "runtime" "strconv" @@ -13,7 +12,6 @@ import ( "github.com/docker/go-units" "github.com/ipfs/go-cid" cbor "github.com/ipfs/go-ipld-cbor" - "golang.org/x/term" "golang.org/x/xerrors" "github.com/filecoin-project/go-address" @@ -2521,9 +2519,7 @@ func UpgradeActorsV14(ctx context.Context, sm *stmgr.StateManager, cache stmgr.M return cid.Undef, xerrors.Errorf("migrating actors v14 state: %w", err) } - if term.IsTerminal(int(os.Stderr.Fd())) { - fmt.Print(upgradeSplash) - } + log.Info("\n\n" + upgradeSplash) return newRoot, nil } diff --git a/node/bundle/bundle.go b/node/bundle/bundle.go index 6e4aa27c1f2..1bdd229e1ec 100644 --- a/node/bundle/bundle.go +++ b/node/bundle/bundle.go @@ -3,11 +3,11 @@ package bundle import ( "bytes" "context" - "fmt" "io" "os" "github.com/ipfs/go-cid" + logging "github.com/ipfs/go-log/v2" "github.com/ipld/go-car" "golang.org/x/xerrors" @@ -19,6 +19,8 @@ import ( "github.com/filecoin-project/lotus/chain/actors" ) +var log = logging.Logger("bundle") + func LoadBundleFromFile(ctx context.Context, bs blockstore.Blockstore, path string) (cid.Cid, error) { f, err := os.Open(path) if err != nil { @@ -55,7 +57,7 @@ func LoadBundles(ctx context.Context, bs blockstore.Blockstore, versions ...acto // All manifests are registered on start, so this must succeed. return xerrors.Errorf("unknown actor version v%d", av) } - fmt.Printf("manifest cid: %s\n", manifestCid) + log.Infof("manifest cid: %s", manifestCid) if haveManifest, err := bs.Has(ctx, manifestCid); err != nil { return xerrors.Errorf("blockstore error when loading manifest %s: %w", manifestCid, err)