From 7c0b6f41d81c1cbd2ee9a0b24c8e9da8c80d33b8 Mon Sep 17 00:00:00 2001 From: yaohcn Date: Tue, 24 Nov 2020 19:09:48 +0800 Subject: [PATCH 1/2] fix log format --- chain/events/events.go | 2 +- chain/sync.go | 2 +- cmd/lotus-fountain/main.go | 2 +- cmd/lotus/daemon.go | 2 +- extern/sector-storage/manager_calltracker.go | 6 +++--- extern/sector-storage/sched.go | 2 +- extern/sector-storage/sched_worker.go | 2 +- extern/storage-sealing/sealing.go | 2 +- extern/storage-sealing/states_failed.go | 6 +++--- lib/rpcenc/reader.go | 4 ++-- 10 files changed, 15 insertions(+), 15 deletions(-) diff --git a/chain/events/events.go b/chain/events/events.go index e35e91366..eaf196c56 100644 --- a/chain/events/events.go +++ b/chain/events/events.go @@ -129,7 +129,7 @@ func (e *Events) listenHeadChangesOnce(ctx context.Context) error { } if err := e.tsc.add(cur[0].Val); err != nil { - log.Warn("tsc.add: adding current tipset failed: %w", err) + log.Warnf("tsc.add: adding current tipset failed: %w", err) } e.readyOnce.Do(func() { diff --git a/chain/sync.go b/chain/sync.go index d5c6f73fd..61c1d2094 100644 --- a/chain/sync.go +++ b/chain/sync.go @@ -1331,7 +1331,7 @@ loop: continue } if !xerrors.Is(err, bstore.ErrNotFound) { - log.Warn("loading local tipset: %s", err) + log.Warnf("loading local tipset: %s", err) } // NB: GetBlocks validates that the blocks are in-fact the ones we diff --git a/cmd/lotus-fountain/main.go b/cmd/lotus-fountain/main.go index ea7190e83..931978d96 100644 --- a/cmd/lotus-fountain/main.go +++ b/cmd/lotus-fountain/main.go @@ -87,7 +87,7 @@ var runCmd = &cli.Command{ return err } - log.Info("Remote version: %s", v.Version) + log.Infof("Remote version: %s", v.Version) from, err := address.NewFromString(cctx.String("from")) if err != nil { diff --git a/cmd/lotus/daemon.go b/cmd/lotus/daemon.go index 1d13b4082..cfe87432d 100644 --- a/cmd/lotus/daemon.go +++ b/cmd/lotus/daemon.go @@ -358,7 +358,7 @@ func importKey(ctx context.Context, api api.FullNode, f string) error { return err } - log.Info("successfully imported key for %s", addr) + log.Infof("successfully imported key for %s", addr) return nil } diff --git a/extern/sector-storage/manager_calltracker.go b/extern/sector-storage/manager_calltracker.go index e2f801303..c3b2e3190 100644 --- a/extern/sector-storage/manager_calltracker.go +++ b/extern/sector-storage/manager_calltracker.go @@ -146,7 +146,7 @@ func (m *Manager) getWork(ctx context.Context, method sealtasks.TaskType, params switch ws.Status { case wsStarted: - log.Warn("canceling started (not running) work %s", wid) + log.Warnf("canceling started (not running) work %s", wid) if err := m.work.Get(wid).End(); err != nil { log.Errorf("cancel: failed to cancel started work %s: %+v", wid, err) @@ -154,9 +154,9 @@ func (m *Manager) getWork(ctx context.Context, method sealtasks.TaskType, params } case wsDone: // TODO: still remove? - log.Warn("cancel called on work %s in 'done' state", wid) + log.Warnf("cancel called on work %s in 'done' state", wid) case wsRunning: - log.Warn("cancel called on work %s in 'running' state (manager shutting down?)", wid) + log.Warnf("cancel called on work %s in 'running' state (manager shutting down?)", wid) } }, nil diff --git a/extern/sector-storage/sched.go b/extern/sector-storage/sched.go index 79761a65e..8787f218b 100644 --- a/extern/sector-storage/sched.go +++ b/extern/sector-storage/sched.go @@ -436,7 +436,7 @@ func (sh *scheduler) trySched() { r, err := task.sel.Cmp(rpcCtx, task.taskType, wi, wj) if err != nil { - log.Error("selecting best worker: %s", err) + log.Errorf("selecting best worker: %s", err) } return r }) diff --git a/extern/sector-storage/sched_worker.go b/extern/sector-storage/sched_worker.go index 7e60cd01b..573aa623b 100644 --- a/extern/sector-storage/sched_worker.go +++ b/extern/sector-storage/sched_worker.go @@ -368,7 +368,7 @@ assignLoop: err := sw.startProcessingTask(sw.taskDone, todo) if err != nil { - log.Error("startProcessingTask error: %+v", err) + log.Errorf("startProcessingTask error: %+v", err) go todo.respond(xerrors.Errorf("startProcessingTask error: %w", err)) } diff --git a/extern/storage-sealing/sealing.go b/extern/storage-sealing/sealing.go index 5211f8bbe..c18dc88fa 100644 --- a/extern/storage-sealing/sealing.go +++ b/extern/storage-sealing/sealing.go @@ -357,7 +357,7 @@ func (m *Sealing) newDealSector(ctx context.Context) (abi.SectorNumber, abi.Sect m.unsealedInfoMap.lk.Unlock() if err := m.StartPacking(best); err != nil { - log.Error("newDealSector StartPacking error: %+v", err) + log.Errorf("newDealSector StartPacking error: %+v", err) continue // let's pretend this is fine } m.unsealedInfoMap.lk.Lock() diff --git a/extern/storage-sealing/states_failed.go b/extern/storage-sealing/states_failed.go index be3f3d35a..e425606de 100644 --- a/extern/storage-sealing/states_failed.go +++ b/extern/storage-sealing/states_failed.go @@ -137,12 +137,12 @@ func (m *Sealing) handlePreCommitFailed(ctx statemachine.Context, sector SectorI if pci, is := m.checkPreCommitted(ctx, sector); is && pci != nil { if sector.PreCommitMessage == nil { - log.Warn("sector %d is precommitted on chain, but we don't have precommit message", sector.SectorNumber) + log.Warnf("sector %d is precommitted on chain, but we don't have precommit message", sector.SectorNumber) return ctx.Send(SectorPreCommitLanded{TipSet: tok}) } if pci.Info.SealedCID != *sector.CommR { - log.Warn("sector %d is precommitted on chain, with different CommR: %x != %x", sector.SectorNumber, pci.Info.SealedCID, sector.CommR) + log.Warnf("sector %d is precommitted on chain, with different CommR: %x != %x", sector.SectorNumber, pci.Info.SealedCID, sector.CommR) return nil // TODO: remove when the actor allows re-precommit } @@ -387,7 +387,7 @@ func (m *Sealing) handleRecoverDealIDs(ctx statemachine.Context, sector SectorIn if p.DealInfo.PublishCid == nil { // TODO: check if we are in an early enough state try to remove this piece - log.Error("can't fix sector deals: piece %d (of %d) of sector %d has nil DealInfo.PublishCid (refers to deal %d)", i, len(sector.Pieces), sector.SectorNumber, p.DealInfo.DealID) + log.Errorf("can't fix sector deals: piece %d (of %d) of sector %d has nil DealInfo.PublishCid (refers to deal %d)", i, len(sector.Pieces), sector.SectorNumber, p.DealInfo.DealID) // Not much to do here (and this can only happen for old spacerace sectors) return ctx.Send(SectorRemove{}) } diff --git a/lib/rpcenc/reader.go b/lib/rpcenc/reader.go index 617c6495e..8bd512705 100644 --- a/lib/rpcenc/reader.go +++ b/lib/rpcenc/reader.go @@ -128,7 +128,7 @@ func ReaderParamDecoder() (http.HandlerFunc, jsonrpc.ServerOption) { case ch <- wr: case <-tctx.Done(): close(ch) - log.Error("context error in reader stream handler (1): %v", tctx.Err()) + log.Errorf("context error in reader stream handler (1): %v", tctx.Err()) resp.WriteHeader(500) return } @@ -136,7 +136,7 @@ func ReaderParamDecoder() (http.HandlerFunc, jsonrpc.ServerOption) { select { case <-wr.wait: case <-req.Context().Done(): - log.Error("context error in reader stream handler (2): %v", req.Context().Err()) + log.Errorf("context error in reader stream handler (2): %v", req.Context().Err()) resp.WriteHeader(500) return } From eb2be69acee6878265da0e2d402eb86c8e9444ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 24 Nov 2020 17:51:19 +0100 Subject: [PATCH 2/2] events: use %v to log errors --- chain/events/events.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chain/events/events.go b/chain/events/events.go index eaf196c56..dcdf6c162 100644 --- a/chain/events/events.go +++ b/chain/events/events.go @@ -129,7 +129,7 @@ func (e *Events) listenHeadChangesOnce(ctx context.Context) error { } if err := e.tsc.add(cur[0].Val); err != nil { - log.Warnf("tsc.add: adding current tipset failed: %w", err) + log.Warnf("tsc.add: adding current tipset failed: %v", err) } e.readyOnce.Do(func() {