Browse Source

Removed Log.File, all log goes out to stdout.

pull/57/head
Jae Kwon 10 years ago
parent
commit
9513f601de
9 changed files with 36 additions and 44 deletions
  1. +1
    -1
      Makefile
  2. +1
    -1
      cmd/barak/seed0
  3. +1
    -1
      cmd/barak/seed1
  4. +1
    -1
      cmd/barak/seed2
  5. +5
    -11
      config/config.go
  6. +3
    -3
      consensus/reactor.go
  7. +21
    -18
      logger/log.go
  8. +1
    -3
      p2p/connection.go
  9. +2
    -5
      p2p/switch.go

+ 1
- 1
Makefile View File

@ -25,7 +25,7 @@ tendermint_root/priv_validator.json: tendermint_root/priv_validator.json.orig
cp $< $@
economy: tendermint_root/priv_validator.json
docker run -v $(CURDIR)/tendermint_root:/tendermint_root -p 8080:8080 tendermint
docker run -v $(CURDIR)/tendermint_root:/tendermint_root -p 46656:46656 tendermint
clean:
rm -f tendermint tendermint_root/priv_validator.json

cmd/barak/seed → cmd/barak/seed0 View File


cmd/barak/seed3 → cmd/barak/seed1 View File


+ 1
- 1
cmd/barak/seed2 View File

@ -1,5 +1,5 @@
{
"ListenAddress": "0.0.0.0:8083",
"ListenAddress": "0.0.0.0:46662",
"Validators": [
{
"VotingPower": 1,


+ 5
- 11
config/config.go View File

@ -37,9 +37,9 @@ var defaultConfig = `# This is a TOML config file.
Moniker = "anonymous"
Network = "tendermint_testnet2"
ListenAddr = "0.0.0.0:8080"
ListenAddr = "0.0.0.0:46656"
# First node to connect to. Command-line overridable.
SeedNode = "188.166.55.222:8080"
SeedNode = "188.166.55.222:46656"
[DB]
# The only other available backend is "memdb"
@ -49,13 +49,9 @@ Backend = "leveldb"
[Log.Stdout]
Level = "info"
[Log.File]
Level = "debug"
# Dir = "~/.tendermint/log"
[RPC.HTTP]
# For the RPC API HTTP server. Port required.
ListenAddr = "0.0.0.0:8081"
ListenAddr = "0.0.0.0:46657"
[Alert]
# TODO: Document options
@ -119,13 +115,11 @@ var DefaultGenesis = `{
func initDefaults(rootDir string) {
app.SetDefault("Moniker", "anonymous")
app.SetDefault("Network", "tendermint_testnet0")
app.SetDefault("ListenAddr", "0.0.0.0:8080")
app.SetDefault("ListenAddr", "0.0.0.0:46656")
app.SetDefault("DB.Backend", "leveldb")
app.SetDefault("DB.Dir", rootDir+"/data")
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:46657")
app.SetDefault("GenesisFile", rootDir+"/genesis.json")
app.SetDefault("AddrBookFile", rootDir+"/addrbook.json")


+ 3
- 3
consensus/reactor.go View File

@ -110,7 +110,7 @@ func (conR *ConsensusReactor) AddPeer(peer *p2p.Peer) {
go conR.gossipVotesRoutine(peer, peerState)
// Send our state to peer.
conR.sendNewRoundStepRoutine(peer)
conR.sendNewRoundStep(peer)
}
// Implements Reactor
@ -118,7 +118,6 @@ func (conR *ConsensusReactor) RemovePeer(peer *p2p.Peer, reason interface{}) {
if !conR.IsRunning() {
return
}
//peer.Data.Get(peerStateKey).(*PeerState).Disconnect()
}
@ -176,6 +175,7 @@ func (conR *ConsensusReactor) Receive(chId byte, peer *p2p.Peer, msgBytes []byte
switch msg := msg_.(type) {
case *VoteMessage:
vote := msg.Vote
// XXX if we're receiving a commit from the last block while...
if rs.Height != vote.Height {
return // Wrong height. Not necessarily a bad peer.
}
@ -288,7 +288,7 @@ func (conR *ConsensusReactor) broadcastNewRoundStepRoutine() {
}
}
func (conR *ConsensusReactor) sendNewRoundStepRoutine(peer *p2p.Peer) {
func (conR *ConsensusReactor) sendNewRoundStep(peer *p2p.Peer) {
rs := conR.conS.GetRoundState()
nrsMsg, csMsg := makeRoundStepMessages(rs)
if nrsMsg != nil {


+ 21
- 18
logger/log.go View File

@ -1,7 +1,6 @@
package logger
import (
"fmt"
"os"
"github.com/tendermint/log15"
@ -19,29 +18,33 @@ func init() {
func Reset() {
handlers := []log15.Handler{}
// By default, there's a stdout terminal format handler.
handlers = append(handlers, log15.LvlFilterHandler(
// stdout handler
stdoutHandler := log15.LvlFilterHandler(
getLevel(config.App().GetString("Log.Stdout.Level")),
log15.StreamHandler(os.Stdout, log15.TerminalFormat()),
))
)
handlers = append(handlers, stdoutHandler)
// Maybe also write to a file.
if _logFileDir := config.App().GetString("Log.File.Dir"); _logFileDir != "" {
// Create log dir if it doesn't exist
err := os.MkdirAll(_logFileDir, 0700)
if err != nil {
fmt.Printf("Could not create directory: %v", err)
os.Exit(1)
/*
// Maybe also write to a file.
if _logFileDir := config.App().GetString("Log.File.Dir"); _logFileDir != "" {
// Create log dir if it doesn't exist
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(
getLevel(config.App().GetString("Log.File.Level")),
log15.Must.FileHandler(_logFileDir+"/tendermint.log", log15.LogfmtFormat()),
))
}
// File handler
handlers = append(handlers, log15.LvlFilterHandler(
getLevel(config.App().GetString("Log.File.Level")),
log15.Must.FileHandler(_logFileDir+"/tendermint.log", log15.LogfmtFormat()),
))
}
*/
// Set rootHandler.
rootHandler = log15.MultiHandler(handlers...)
//rootHandler = log15.MultiHandler(handlers...)
rootHandler = stdoutHandler
// By setting handlers on the root, we handle events from all loggers.
log15.Root().SetHandler(rootHandler)


+ 1
- 3
p2p/connection.go View File

@ -154,9 +154,7 @@ func (c *MConnection) String() string {
func (c *MConnection) flush() {
err := c.bufWriter.Flush()
if err != nil {
if atomic.LoadUint32(&c.stopped) != 1 {
log.Warn("MConnection flush failed", "error", err)
}
log.Warn("MConnection flush failed", "error", err)
}
}


+ 2
- 5
p2p/switch.go View File

@ -181,11 +181,8 @@ func (sw *Switch) AddPeerWithConnection(conn net.Conn, outbound bool) (*Peer, er
}
func (sw *Switch) startInitPeer(peer *Peer) {
// Start the peer
peer.start()
// Notify reactors
sw.doAddPeer(peer)
sw.addPeerToReactors(peer)
}
func (sw *Switch) DialPeerWithAddress(addr *NetAddress) (*Peer, error) {
@ -266,7 +263,7 @@ func (sw *Switch) StopPeerGracefully(peer *Peer) {
sw.doRemovePeer(peer, nil)
}
func (sw *Switch) doAddPeer(peer *Peer) {
func (sw *Switch) addPeerToReactors(peer *Peer) {
for _, reactor := range sw.reactors {
reactor.AddPeer(peer)
}


Loading…
Cancel
Save