initialize ethereum logger

This commit is contained in:
Andrea Franz 2018-10-19 11:34:05 +02:00
parent 30981c77a9
commit d4c75f7783
No known key found for this signature in database
GPG Key ID: 4F0D2F2D9DE7F29D
1 changed files with 13 additions and 5 deletions

View File

@ -5,11 +5,11 @@ import (
"fmt"
stdlog "log"
"os"
"strings"
"github.com/ebfe/scard"
"github.com/ethereum/go-ethereum/log"
"github.com/status-im/smartcard-go/lightwallet"
"github.com/status-im/status-go/logutils"
)
type commandFunc func(*lightwallet.Installer) error
@ -25,12 +25,20 @@ var (
flagLogLevel = flag.String("l", "", `Log level, one of: "ERROR", "WARN", "INFO", "DEBUG", and "TRACE"`)
)
func initLogger() {
level, err := log.LvlFromString(strings.ToLower(*flagLogLevel))
if err != nil {
stdlog.Fatal(err)
}
handler := log.StreamHandler(os.Stderr, log.TerminalFormat(true))
filteredHandler := log.LvlFilterHandler(level, handler)
log.Root().SetHandler(filteredHandler)
}
func init() {
flag.Parse()
if err := logutils.OverrideRootLog(true, *flagLogLevel, "", true); err != nil {
stdlog.Fatalf("Error initializing logger: %v", err)
}
initLogger()
commands = map[string]commandFunc{
"install": commandInstall,