Browse Source

Less log lines to STDOUT

pull/39/head
Jae Kwon 10 years ago
parent
commit
687815f6ed
6 changed files with 36 additions and 21 deletions
  1. +0
    -2
      block/block.go
  2. +12
    -5
      config/config.go
  3. +1
    -1
      consensus/state.go
  4. +14
    -5
      logger/log.go
  5. +8
    -7
      p2p/pex_reactor.go
  6. +1
    -1
      p2p/switch.go

+ 0
- 2
block/block.go View File

@ -120,10 +120,8 @@ func (h *Header) Hash() []byte {
if *err != nil { if *err != nil {
panic(err) panic(err)
} }
log.Debug("Hashing", "bytes", buf.Bytes())
hasher.Write(buf.Bytes()) hasher.Write(buf.Bytes())
hash := hasher.Sum(nil) hash := hasher.Sum(nil)
log.Debug("Hashing got", "hash", hash)
return hash return hash
} }


+ 12
- 5
config/config.go View File

@ -21,13 +21,19 @@ var defaultConfig = `# This is a TOML config file.
Network = "tendermint_testnet0" Network = "tendermint_testnet0"
ListenAddr = "0.0.0.0:8080" ListenAddr = "0.0.0.0:8080"
# First node to connect to. Command-line overridable. # First node to connect to. Command-line overridable.
# SeedNode = "a.b.c.d:pppp"
SeedNode = "23.239.22.253:8080"
[DB] [DB]
# The only other available backend is "memdb" # The only other available backend is "memdb"
Backend = "leveldb" Backend = "leveldb"
# The leveldb data directory.
# Dir = "<YOUR_HOME_DIRECTORY>/.tendermint/data"
# Dir = "~/.tendermint/data"
[Log.Stdout]
Level = "info"
[Log.File]
Level = "debug"
# Dir = "~/.tendermint/log"
[RPC.HTTP] [RPC.HTTP]
# For the RPC API HTTP server. Port required. # For the RPC API HTTP server. Port required.
@ -46,8 +52,9 @@ func initDefaults() {
App.SetDefault("ListenAddr", "0.0.0.0:8080") App.SetDefault("ListenAddr", "0.0.0.0:8080")
App.SetDefault("DB.Backend", "leveldb") App.SetDefault("DB.Backend", "leveldb")
App.SetDefault("DB.Dir", rootDir+"/data") App.SetDefault("DB.Dir", rootDir+"/data")
App.SetDefault("Log.Level", "debug")
App.SetDefault("Log.Dir", rootDir+"/log")
App.SetDefault("Log.Stdout.Level", "info")
App.SetDefault("Log.File.Dir", rootDir+"/log")
App.SetDefault("Log.File.Level", "debug")
App.SetDefault("RPC.HTTP.ListenAddr", "0.0.0.0:8081") App.SetDefault("RPC.HTTP.ListenAddr", "0.0.0.0:8081")
App.SetDefault("GenesisFile", rootDir+"/genesis.json") App.SetDefault("GenesisFile", rootDir+"/genesis.json")


+ 1
- 1
consensus/state.go View File

@ -315,7 +315,7 @@ func (cs *ConsensusState) stepTransitionRoutine() {
// we're running in a separate goroutine, which avoids deadlocks. // we're running in a separate goroutine, which avoids deadlocks.
rs := cs.getRoundState() rs := cs.getRoundState()
round, roundStartTime, roundDuration, _, elapsedRatio := calcRoundInfo(rs.StartTime) round, roundStartTime, roundDuration, _, elapsedRatio := calcRoundInfo(rs.StartTime)
log.Info("Scheduling next action", "height", rs.Height, "round", round, "step", rs.Step, "roundStartTime", roundStartTime, "elapsedRatio", elapsedRatio)
log.Debug("Scheduling next action", "height", rs.Height, "round", round, "step", rs.Step, "roundStartTime", roundStartTime, "elapsedRatio", elapsedRatio)
switch rs.Step { switch rs.Step {
case RoundStepNewHeight: case RoundStepNewHeight:
// We should run RoundActionPropose when rs.StartTime passes. // We should run RoundActionPropose when rs.StartTime passes.


+ 14
- 5
logger/log.go View File

@ -5,32 +5,41 @@ import (
"os" "os"
"github.com/tendermint/log15" "github.com/tendermint/log15"
. "github.com/tendermint/tendermint/common"
"github.com/tendermint/tendermint/config" "github.com/tendermint/tendermint/config"
) )
var rootHandler log15.Handler var rootHandler log15.Handler
func getLevel(lvlString string) log15.Lvl {
lvl, err := log15.LvlFromString(lvlString)
if err != nil {
Exit(Fmt("Invalid log level %v: %v", lvlString, err))
}
return lvl
}
func init() { func init() {
handlers := []log15.Handler{} handlers := []log15.Handler{}
// By default, there's a stdout terminal format handler. // By default, there's a stdout terminal format handler.
handlers = append(handlers, log15.LvlFilterHandler( handlers = append(handlers, log15.LvlFilterHandler(
log15.LvlDebug,
getLevel(config.App.GetString("Log.Stdout.Level")),
log15.StreamHandler(os.Stdout, log15.TerminalFormat()), log15.StreamHandler(os.Stdout, log15.TerminalFormat()),
)) ))
// Maybe also write to a file. // Maybe also write to a file.
if config.App.GetString("Log.Dir") != "" {
if _logFileDir := config.App.GetString("Log.File.Dir"); _logFileDir != "" {
// Create log dir if it doesn't exist // Create log dir if it doesn't exist
err := os.MkdirAll(config.App.GetString("Log.Dir"), 0700)
err := os.MkdirAll(_logFileDir, 0700)
if err != nil { if err != nil {
fmt.Printf("Could not create directory: %v", err) fmt.Printf("Could not create directory: %v", err)
os.Exit(1) os.Exit(1)
} }
// File handler // File handler
handlers = append(handlers, log15.LvlFilterHandler( handlers = append(handlers, log15.LvlFilterHandler(
log15.LvlDebug,
log15.Must.FileHandler(config.App.GetString("Log.Dir")+"/tendermint.log", log15.LogfmtFormat()),
getLevel(config.App.GetString("Log.File.Level")),
log15.Must.FileHandler(_logFileDir+"/tendermint.log", log15.LogfmtFormat()),
)) ))
} }


+ 8
- 7
p2p/pex_reactor.go View File

@ -152,7 +152,7 @@ FOR_LOOP:
func (pexR *PEXReactor) ensurePeers() { func (pexR *PEXReactor) ensurePeers() {
numOutPeers, _, numDialing := pexR.sw.NumPeers() numOutPeers, _, numDialing := pexR.sw.NumPeers()
numToDial := minNumOutboundPeers - (numOutPeers + numDialing) numToDial := minNumOutboundPeers - (numOutPeers + numDialing)
log.Info("Ensure peers", "numOutPeers", numOutPeers, "numDialing", numDialing, "numToDial", numToDial)
log.Debug("Ensure peers", "numOutPeers", numOutPeers, "numDialing", numDialing, "numToDial", numToDial)
if numToDial <= 0 { if numToDial <= 0 {
return return
} }
@ -166,15 +166,16 @@ func (pexR *PEXReactor) ensurePeers() {
// Try to fetch a new peer 3 times. // Try to fetch a new peer 3 times.
// This caps the maximum number of tries to 3 * numToDial. // This caps the maximum number of tries to 3 * numToDial.
for j := 0; j < 3; j++ { for j := 0; j < 3; j++ {
picked = pexR.book.PickAddress(newBias)
if picked == nil {
return
try := pexR.book.PickAddress(newBias)
if try == nil {
break
} }
if toDial.Has(picked.String()) ||
pexR.sw.IsDialing(picked) ||
pexR.sw.Peers().Has(picked.String()) {
if toDial.Has(try.String()) ||
pexR.sw.IsDialing(try) ||
pexR.sw.Peers().Has(try.String()) {
continue continue
} else { } else {
picked = try
break break
} }
} }


+ 1
- 1
p2p/switch.go View File

@ -45,7 +45,7 @@ var (
) )
const ( const (
peerDialTimeoutSeconds = 30
peerDialTimeoutSeconds = 3
) )
func NewSwitch(reactors []Reactor) *Switch { func NewSwitch(reactors []Reactor) *Switch {


Loading…
Cancel
Save