From 36452afd4e31083d748155e5e5ddd682128aa9b0 Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 3 Apr 2015 17:09:01 +0200 Subject: glog wip --- cmd/geth/main.go | 2 ++ cmd/utils/flags.go | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) (limited to 'cmd') diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 62e30ac9a..a5c51d831 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -234,6 +234,8 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.ProtocolVersionFlag, utils.NetworkIdFlag, utils.RPCCORSDomainFlag, + utils.BacktraceAtFlag, + utils.LogToStdErrFlag, } // missing: diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index e82fd9c28..e370cddec 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -15,6 +15,7 @@ import ( "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/logger" + "github.com/ethereum/go-ethereum/logger/glog" "github.com/ethereum/go-ethereum/p2p/nat" "github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/xeth" @@ -184,6 +185,15 @@ var ( Usage: "JS library path to be used with console and js subcommands", Value: ".", } + BacktraceAtFlag = cli.GenericFlag{ + Name: "backtrace_at", + Usage: "When set to a file and line number holding a logging statement a stack trace will be written to the Info log", + Value: glog.GetTraceLocation(), + } + LogToStdErrFlag = cli.BoolFlag{ + Name: "logtostderr", + Usage: "Logs are written to standard error instead of to files.", + } ) func GetNAT(ctx *cli.Context) nat.Interface { @@ -213,6 +223,15 @@ func GetNodeKey(ctx *cli.Context) (key *ecdsa.PrivateKey) { } func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { + // Set verbosity on glog + glog.SetV(ctx.GlobalInt(LogLevelFlag.Name)) + // Set the log type + glog.SetToStderr(ctx.GlobalBool(LogToStdErrFlag.Name)) + + glog.V(2).Infoln("test it") + + glog.V(3).Infoln("other stuff") + return ð.Config{ Name: common.MakeName(clientID, version), DataDir: ctx.GlobalString(DataDirFlag.Name), -- cgit