diff options
author | Determinant <[email protected]> | 2019-08-15 00:40:08 -0400 |
---|---|---|
committer | Determinant <[email protected]> | 2019-08-15 00:40:08 -0400 |
commit | d271cc649e34963507411d4915512353ae1780e4 (patch) | |
tree | 91cf978b1c207719ad14e4766516add5ad360f62 /coreth.go | |
parent | 03513e267d25b5086b3f905b6d1bc5635fcda845 (diff) |
enable colored log
Diffstat (limited to 'coreth.go')
-rw-r--r-- | coreth.go | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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) +} |