aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreth.go10
-rw-r--r--examples/payments/main.go2
-rw-r--r--miner/worker.go11
3 files changed, 14 insertions, 9 deletions
diff --git a/coreth.go b/coreth.go
index e5bbef9..06471a9 100644
--- a/coreth.go
+++ b/coreth.go
@@ -2,16 +2,18 @@ package coreth
import (
"io"
+ "os"
"crypto/ecdsa"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/common"
- //"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/event"
"github.com/Determinant/coreth/eth"
"github.com/Determinant/coreth/node"
"github.com/Determinant/coreth/consensus/dummy"
"github.com/ethereum/go-ethereum/crypto"
+ "github.com/ethereum/go-ethereum/log"
+ "github.com/mattn/go-isatty"
)
type Tx = types.Transaction
@@ -91,3 +93,9 @@ func NewKey(rand io.Reader) (*Key, error) {
}
return NewKeyFromECDSA(privateKeyECDSA), nil
}
+
+func init() {
+ usecolor := (isatty.IsTerminal(os.Stderr.Fd()) || isatty.IsCygwinTerminal(os.Stderr.Fd())) && os.Getenv("TERM") != "dumb"
+ glogger := log.StreamHandler(io.Writer(os.Stderr), log.TerminalFormat(usecolor))
+ log.Root().SetHandler(glogger)
+}
diff --git a/examples/payments/main.go b/examples/payments/main.go
index 8a1dca8..4445406 100644
--- a/examples/payments/main.go
+++ b/examples/payments/main.go
@@ -13,7 +13,6 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/Determinant/coreth/eth"
"github.com/Determinant/coreth"
- "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/common"
)
@@ -23,7 +22,6 @@ func checkError(err error) {
}
func main() {
- log.Root().SetHandler(log.StderrHandler)
config := eth.DefaultConfig
chainConfig := &params.ChainConfig {
ChainID: big.NewInt(1),
diff --git a/miner/worker.go b/miner/worker.go
index c1a82ce..304c014 100644
--- a/miner/worker.go
+++ b/miner/worker.go
@@ -363,7 +363,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
clearPending(w.chain.CurrentBlock().NumberU64())
timestamp = time.Now().Unix()
if !w.manualMining {
- log.Warn("commit ch")
+ log.Trace("commit ch")
commit(false, commitInterruptNewHead)
}
@@ -371,7 +371,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
clearPending(head.Block.NumberU64())
timestamp = time.Now().Unix()
if !w.manualMining {
- log.Warn("commit update")
+ log.Trace("commit update")
commit(false, commitInterruptNewHead)
}
@@ -384,7 +384,7 @@ func (w *worker) newWorkLoop(recommit time.Duration) {
timer.Reset(recommit)
continue
}
- log.Warn("commit resubmit")
+ log.Trace("commit resubmit")
commit(true, commitInterruptResubmit)
}
@@ -451,7 +451,6 @@ func (w *worker) mainLoop() {
// If our mining block contains less than 2 uncle blocks,
// add the new uncle block if valid and regenerate a mining block.
if w.isRunning() && w.current != nil && w.current.uncles.Cardinality() < 2 && !w.manualUncle {
- log.Warn("wtf")
start := time.Now()
if err := w.commitUncle(w.current, ev.Block.Header()); err == nil {
var uncles []*types.Header
@@ -949,7 +948,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
if !noempty && !w.manualUncle {
// Create an empty block based on temporary copied state for sealing in advance without waiting block
// execution finished.
- log.Warn("commit n1")
+ log.Trace("commit n1")
w.commit(uncles, nil, false, tstart)
}
@@ -984,7 +983,7 @@ func (w *worker) commitNewWork(interrupt *int32, noempty bool, timestamp int64)
return
}
}
- log.Warn("commit n2")
+ log.Trace("commit n2")
w.commit(uncles, w.fullTaskHook, true, tstart)
}