diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-05 05:04:19 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-05 05:04:19 +0800 |
commit | 053d5552abdbc4cf41376149b141e24a01713e5a (patch) | |
tree | 8083ace145e4270f4a72e35fff2af0ec5e37cc38 /miner | |
parent | 5dc5e669864153949899b7a7c37737be65b80ba1 (diff) | |
download | dexon-053d5552abdbc4cf41376149b141e24a01713e5a.tar dexon-053d5552abdbc4cf41376149b141e24a01713e5a.tar.gz dexon-053d5552abdbc4cf41376149b141e24a01713e5a.tar.bz2 dexon-053d5552abdbc4cf41376149b141e24a01713e5a.tar.lz dexon-053d5552abdbc4cf41376149b141e24a01713e5a.tar.xz dexon-053d5552abdbc4cf41376149b141e24a01713e5a.tar.zst dexon-053d5552abdbc4cf41376149b141e24a01713e5a.zip |
Updated logging
Diffstat (limited to 'miner')
-rw-r--r-- | miner/agent.go | 4 | ||||
-rw-r--r-- | miner/miner.go | 3 | ||||
-rw-r--r-- | miner/worker.go | 24 |
3 files changed, 18 insertions, 13 deletions
diff --git a/miner/agent.go b/miner/agent.go index ad08e3841..547fdfbef 100644 --- a/miner/agent.go +++ b/miner/agent.go @@ -5,6 +5,8 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" + "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/pow" ) @@ -75,7 +77,7 @@ done: } func (self *CpuMiner) mine(block *types.Block) { - minerlogger.Debugf("(re)started agent[%d]. mining...\n", self.index) + glog.V(logger.Debug).Infof("(re)started agent[%d]. mining...\n", self.index) // Reset the channel self.chMu.Lock() diff --git a/miner/miner.go b/miner/miner.go index cf84c11f3..581de9674 100644 --- a/miner/miner.go +++ b/miner/miner.go @@ -6,12 +6,9 @@ import ( "github.com/ethereum/ethash" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" - "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/pow" ) -var minerlogger = logger.NewLogger("MINER") - type Miner struct { worker *worker diff --git a/miner/worker.go b/miner/worker.go index 77b8406cb..8541100d1 100644 --- a/miner/worker.go +++ b/miner/worker.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/pow" "gopkg.in/fatih/set.v0" ) @@ -144,7 +145,9 @@ out: } break out case <-timer.C: - minerlogger.Infoln("Hash rate:", self.HashRate(), "Khash") + if glog.V(logger.Info) { + glog.Infoln("Hash rate:", self.HashRate(), "Khash") + } // XXX In case all mined a possible uncle if atomic.LoadInt64(&self.atWork) == 0 { @@ -171,7 +174,7 @@ func (self *worker) wait() { } self.mux.Post(core.NewMinedBlockEvent{block}) - minerlogger.Infof("🔨 Mined block #%v", block.Number()) + glog.V(logger.Info).Infof("🔨 Mined block #%v", block.Number()) jsonlogger.LogJson(&logger.EthMinerNewBlock{ BlockHash: block.Hash().Hex(), @@ -238,10 +241,13 @@ gasLimit: from, _ := tx.From() self.chain.TxState().RemoveNonce(from, tx.Nonce()) remove = append(remove, tx) - minerlogger.Infof("TX (%x) failed, will be removed: %v\n", tx.Hash().Bytes()[:4], err) - minerlogger.Infoln(tx) + + if glog.V(logger.Info) { + glog.Infof("TX (%x) failed, will be removed: %v\n", tx.Hash().Bytes()[:4], err) + } + glog.V(logger.Debug).Infoln(tx) case state.IsGasLimitErr(err): - minerlogger.Infof("Gas limit reached for block. %d TXs included in this block\n", i) + glog.V(logger.Info).Infof("Gas limit reached for block. %d TXs included in this block\n", i) // Break on gas limit break gasLimit default: @@ -260,15 +266,15 @@ gasLimit: } if err := self.commitUncle(uncle.Header()); err != nil { - minerlogger.Infof("Bad uncle found and will be removed (%x)\n", hash[:4]) - minerlogger.Debugln(uncle) + glog.V(logger.Info).Infof("Bad uncle found and will be removed (%x)\n", hash[:4]) + glog.V(logger.Debug).Infoln(uncle) badUncles = append(badUncles, hash) } else { - minerlogger.Infof("commiting %x as uncle\n", hash[:4]) + glog.V(logger.Info).Infof("commiting %x as uncle\n", hash[:4]) uncles = append(uncles, uncle.Header()) } } - minerlogger.Infof("commit new work on block %v with %d txs & %d uncles\n", self.current.block.Number(), tcount, len(uncles)) + glog.V(logger.Info).Infof("commit new work on block %v with %d txs & %d uncles\n", self.current.block.Number(), tcount, len(uncles)) for _, hash := range badUncles { delete(self.possibleUncles, hash) } |