Browse Source

Service log prettify

pull/117/head
Jae Kwon 10 years ago
parent
commit
c0a64d74be
4 changed files with 16 additions and 5 deletions
  1. +2
    -2
      Godeps/_workspace/src/github.com/tendermint/log15/logger.go
  2. +7
    -0
      common/service.go
  3. +4
    -0
      consensus/state.go
  4. +3
    -3
      p2p/switch_test.go

+ 2
- 2
Godeps/_workspace/src/github.com/tendermint/log15/logger.go View File

@ -30,7 +30,7 @@ func (l Lvl) String() string {
case LvlInfo: case LvlInfo:
return "info" return "info"
case LvlNotice: case LvlNotice:
return "notice"
return "note"
case LvlWarn: case LvlWarn:
return "warn" return "warn"
case LvlError: case LvlError:
@ -50,7 +50,7 @@ func LvlFromString(lvlString string) (Lvl, error) {
return LvlDebug, nil return LvlDebug, nil
case "info": case "info":
return LvlInfo, nil return LvlInfo, nil
case "notice":
case "note":
return LvlNotice, nil return LvlNotice, nil
case "warn": case "warn":
return LvlWarn, nil return LvlWarn, nil


+ 7
- 0
common/service.go View File

@ -49,6 +49,8 @@ type Service interface {
AfterStop() AfterStop()
IsRunning() bool IsRunning() bool
String() string
} }
type BaseService struct { type BaseService struct {
@ -117,6 +119,11 @@ func (bs *BaseService) IsRunning() bool {
return atomic.LoadUint32(&bs.started) == 1 && atomic.LoadUint32(&bs.stopped) == 0 return atomic.LoadUint32(&bs.started) == 1 && atomic.LoadUint32(&bs.stopped) == 0
} }
// Implements Servce
func (bs *BaseService) String() string {
return bs.name
}
//---------------------------------------- //----------------------------------------
type QuitService struct { type QuitService struct {


+ 4
- 0
consensus/state.go View File

@ -1227,3 +1227,7 @@ func (cs *ConsensusState) saveBlock(block *types.Block, blockParts *types.PartSe
func (cs *ConsensusState) SetFireable(evsw events.Fireable) { func (cs *ConsensusState) SetFireable(evsw events.Fireable) {
cs.evsw = evsw cs.evsw = evsw
} }
func (cs *ConsensusState) String() string {
return Fmt("ConsensusState(H:%v R:%v S:%v", cs.Height, cs.Round, cs.Step)
}

+ 3
- 3
p2p/switch_test.go View File

@ -92,7 +92,7 @@ func makeSwitchPair(t testing.TB, initSwitch func(*Switch) *Switch) (*Switch, *S
}) })
s2.SetNodePrivKey(s2PrivKey) s2.SetNodePrivKey(s2PrivKey)
// Start switches
// Start switches and reactors
s1.Start() s1.Start()
s2.Start() s2.Start()
@ -130,11 +130,11 @@ func TestSwitches(t *testing.T) {
sw.AddReactor("foo", NewTestReactor([]*ChannelDescriptor{ sw.AddReactor("foo", NewTestReactor([]*ChannelDescriptor{
&ChannelDescriptor{Id: byte(0x00), Priority: 10}, &ChannelDescriptor{Id: byte(0x00), Priority: 10},
&ChannelDescriptor{Id: byte(0x01), Priority: 10}, &ChannelDescriptor{Id: byte(0x01), Priority: 10},
}, true)).Start() // Start the reactor
}, true))
sw.AddReactor("bar", NewTestReactor([]*ChannelDescriptor{ sw.AddReactor("bar", NewTestReactor([]*ChannelDescriptor{
&ChannelDescriptor{Id: byte(0x02), Priority: 10}, &ChannelDescriptor{Id: byte(0x02), Priority: 10},
&ChannelDescriptor{Id: byte(0x03), Priority: 10}, &ChannelDescriptor{Id: byte(0x03), Priority: 10},
}, true)).Start() // Start the reactor
}, true))
return sw return sw
}) })
defer s1.Stop() defer s1.Stop()


Loading…
Cancel
Save