initialize ethereum logger
This commit is contained in:
parent
30981c77a9
commit
d4c75f7783
|
@ -5,11 +5,11 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
stdlog "log"
|
stdlog "log"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/ebfe/scard"
|
"github.com/ebfe/scard"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/status-im/smartcard-go/lightwallet"
|
"github.com/status-im/smartcard-go/lightwallet"
|
||||||
"github.com/status-im/status-go/logutils"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type commandFunc func(*lightwallet.Installer) error
|
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"`)
|
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() {
|
func init() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
initLogger()
|
||||||
if err := logutils.OverrideRootLog(true, *flagLogLevel, "", true); err != nil {
|
|
||||||
stdlog.Fatalf("Error initializing logger: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
commands = map[string]commandFunc{
|
commands = map[string]commandFunc{
|
||||||
"install": commandInstall,
|
"install": commandInstall,
|
||||||
|
|
Loading…
Reference in New Issue