aboutsummaryrefslogtreecommitdiff
path: root/coreth.go
diff options
context:
space:
mode:
authorDeterminant <ted.sybil@gmail.com>2019-08-15 00:40:08 -0400
committerDeterminant <ted.sybil@gmail.com>2019-08-15 00:40:08 -0400
commitd271cc649e34963507411d4915512353ae1780e4 (patch)
tree91cf978b1c207719ad14e4766516add5ad360f62 /coreth.go
parent03513e267d25b5086b3f905b6d1bc5635fcda845 (diff)
enable colored log
Diffstat (limited to 'coreth.go')
-rw-r--r--coreth.go10
1 files changed, 9 insertions, 1 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)
+}