Service log prettify

This commit is contained in:
Jae Kwon 2015-07-20 16:55:05 -07:00
parent 1d362a71ed
commit c0a64d74be
4 changed files with 16 additions and 5 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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)
}

View File

@ -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()