From c0a64d74be17c118a04b0eed7f721fd21cfb1c78 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Mon, 20 Jul 2015 16:55:05 -0700 Subject: [PATCH] Service log prettify --- .../_workspace/src/github.com/tendermint/log15/logger.go | 4 ++-- common/service.go | 7 +++++++ consensus/state.go | 4 ++++ p2p/switch_test.go | 6 +++--- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Godeps/_workspace/src/github.com/tendermint/log15/logger.go b/Godeps/_workspace/src/github.com/tendermint/log15/logger.go index 99b91876a..bef6031e9 100644 --- a/Godeps/_workspace/src/github.com/tendermint/log15/logger.go +++ b/Godeps/_workspace/src/github.com/tendermint/log15/logger.go @@ -30,7 +30,7 @@ func (l Lvl) String() string { case LvlInfo: return "info" case LvlNotice: - return "notice" + return "note" case LvlWarn: return "warn" case LvlError: @@ -50,7 +50,7 @@ func LvlFromString(lvlString string) (Lvl, error) { return LvlDebug, nil case "info": return LvlInfo, nil - case "notice": + case "note": return LvlNotice, nil case "warn": return LvlWarn, nil diff --git a/common/service.go b/common/service.go index f3829ee0a..97df343f7 100644 --- a/common/service.go +++ b/common/service.go @@ -49,6 +49,8 @@ type Service interface { AfterStop() IsRunning() bool + + String() string } type BaseService struct { @@ -117,6 +119,11 @@ func (bs *BaseService) IsRunning() bool { return atomic.LoadUint32(&bs.started) == 1 && atomic.LoadUint32(&bs.stopped) == 0 } +// Implements Servce +func (bs *BaseService) String() string { + return bs.name +} + //---------------------------------------- type QuitService struct { diff --git a/consensus/state.go b/consensus/state.go index d09b9e079..3fabfebd4 100644 --- a/consensus/state.go +++ b/consensus/state.go @@ -1227,3 +1227,7 @@ func (cs *ConsensusState) saveBlock(block *types.Block, blockParts *types.PartSe func (cs *ConsensusState) SetFireable(evsw events.Fireable) { cs.evsw = evsw } + +func (cs *ConsensusState) String() string { + return Fmt("ConsensusState(H:%v R:%v S:%v", cs.Height, cs.Round, cs.Step) +} diff --git a/p2p/switch_test.go b/p2p/switch_test.go index 89e417a44..571a2691d 100644 --- a/p2p/switch_test.go +++ b/p2p/switch_test.go @@ -92,7 +92,7 @@ func makeSwitchPair(t testing.TB, initSwitch func(*Switch) *Switch) (*Switch, *S }) s2.SetNodePrivKey(s2PrivKey) - // Start switches + // Start switches and reactors s1.Start() s2.Start() @@ -130,11 +130,11 @@ func TestSwitches(t *testing.T) { sw.AddReactor("foo", NewTestReactor([]*ChannelDescriptor{ &ChannelDescriptor{Id: byte(0x00), Priority: 10}, &ChannelDescriptor{Id: byte(0x01), Priority: 10}, - }, true)).Start() // Start the reactor + }, true)) sw.AddReactor("bar", NewTestReactor([]*ChannelDescriptor{ &ChannelDescriptor{Id: byte(0x02), Priority: 10}, &ChannelDescriptor{Id: byte(0x03), Priority: 10}, - }, true)).Start() // Start the reactor + }, true)) return sw }) defer s1.Stop()