Less log lines to STDOUT

This commit is contained in:
Jae Kwon 2015-01-20 15:31:31 -08:00
parent b7b1d6a596
commit 687815f6ed
6 changed files with 36 additions and 21 deletions

View File

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

View File

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

View File

@ -315,7 +315,7 @@ func (cs *ConsensusState) stepTransitionRoutine() {
// we're running in a separate goroutine, which avoids deadlocks.
rs := cs.getRoundState()
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 {
case RoundStepNewHeight:
// We should run RoundActionPropose when rs.StartTime passes.

View File

@ -5,32 +5,41 @@ import (
"os"
"github.com/tendermint/log15"
. "github.com/tendermint/tendermint/common"
"github.com/tendermint/tendermint/config"
)
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() {
handlers := []log15.Handler{}
// By default, there's a stdout terminal format handler.
handlers = append(handlers, log15.LvlFilterHandler(
log15.LvlDebug,
getLevel(config.App.GetString("Log.Stdout.Level")),
log15.StreamHandler(os.Stdout, log15.TerminalFormat()),
))
// 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
err := os.MkdirAll(config.App.GetString("Log.Dir"), 0700)
err := os.MkdirAll(_logFileDir, 0700)
if err != nil {
fmt.Printf("Could not create directory: %v", err)
os.Exit(1)
}
// File handler
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()),
))
}

View File

@ -152,7 +152,7 @@ FOR_LOOP:
func (pexR *PEXReactor) ensurePeers() {
numOutPeers, _, numDialing := pexR.sw.NumPeers()
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 {
return
}
@ -166,15 +166,16 @@ func (pexR *PEXReactor) ensurePeers() {
// Try to fetch a new peer 3 times.
// This caps the maximum number of tries to 3 * numToDial.
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
} else {
picked = try
break
}
}

View File

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