redirect logging to datadir

This commit is contained in:
Daniel Whitenack 2016-06-29 17:48:21 -05:00
parent e118c53e7e
commit 89a6b09212
5 changed files with 126 additions and 96 deletions

188
src/Godeps/Godeps.json generated
View File

@ -22,238 +22,238 @@
},
{
"ImportPath": "github.com/ethereum/go-ethereum/accounts",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/accounts/abi",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/accounts/abi/bind",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/cmd/utils",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/common",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/common/compiler",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/common/httpclient",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/common/registrar",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/common/registrar/ethreg",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/core",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/core/state",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/core/types",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/core/vm",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/crypto",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/crypto/ecies",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/crypto/randentropy",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/crypto/secp256k1",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/crypto/sha3",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/eth",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/eth/downloader",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/eth/fetcher",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/eth/filters",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/eth/gasprice",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/ethapi",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/ethdb",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/event",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/event/filter",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/internal/debug",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/jsre",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/les",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/les/flowcontrol",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/light",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/logger",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/logger/glog",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/metrics",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/miner",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/node",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/p2p",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/p2p/discover",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/p2p/nat",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/params",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/pow",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/release",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/rlp",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/rpc",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/trie",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/ethereum/go-ethereum/whisper",
"Comment": "v1.0.1-897-g3144839",
"Rev": "31448394c8ee75b73b5a5931ea9e2e8b3564a0de"
"Comment": "v1.0.1-898-g6b7ca77",
"Rev": "6b7ca77653ec3b39c0871b5128d7d14ceb2234d9"
},
{
"ImportPath": "github.com/fatih/color",

View File

@ -39,6 +39,8 @@ func main() {
// Placeholder for anything we want to run by default
fmt.Println("You are running statusgo!")
createAndStartNode(".ethereum")
}
// MakeNode create a geth node entity
@ -48,6 +50,7 @@ func MakeNode(datadir string) *node.Node {
set.Bool("shh", true, "whisper")
set.Bool("noeth", true, "disable eth")
set.String("datadir", datadir, "data directory for geth")
set.String("logdir", datadir, "log dir for glog")
c = cli.NewContext(nil, set, nil)
// Construct the textual version string from the individual components
@ -60,6 +63,7 @@ func MakeNode(datadir string) *node.Node {
rConfig.Minor = uint32(versionMinor)
rConfig.Patch = uint32(versionPatch)
utils.DebugSetup(c)
currentNode, accountSync = utils.MakeSystemNode(clientIdentifier, vString, rConfig, makeDefaultExtra(), c)
return currentNode

View File

@ -40,6 +40,7 @@ import (
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/internal/debug"
"github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/light"
"github.com/ethereum/go-ethereum/logger"
@ -414,6 +415,13 @@ var (
}
)
// DebugSetup sets up the debugging parameters such that logs can be retrieved when a
// node is started via importing go-ethereum packages, as opposed to starting via CLI
func DebugSetup(ctx *cli.Context) error {
err := debug.Setup(ctx)
return err
}
// MustMakeDataDir retrieves the currently requested data directory, terminating
// if none (or the empty string) is specified. If the node is starting a testnet,
// the a subdirectory of the specified datadir will be used.

View File

@ -84,6 +84,12 @@ func (*HandlerT) GcStats() *debug.GCStats {
return s
}
// SetLogDir overwrites the default log file utilized by glog
func (h *HandlerT) SetLogDir(logDir string) error {
glog.SetLogDir(logDir)
return nil
}
// CpuProfile turns on CPU profiling for nsec seconds and writes
// profile data to file.
func (h *HandlerT) CpuProfile(file string, nsec uint) error {

View File

@ -43,6 +43,10 @@ var (
Usage: "Request a stack trace at a specific logging statement (e.g. \"block.go:271\")",
Value: glog.GetTraceLocation(),
}
logdirFlag = cli.StringFlag{
Name: "logdir",
Usage: "Request that glog use the specified log dir location",
}
pprofFlag = cli.BoolFlag{
Name: "pprof",
Usage: "Enable the pprof HTTP server",
@ -73,7 +77,7 @@ var (
// Flags holds all command-line flags required for debugging.
var Flags = []cli.Flag{
verbosityFlag, vmoduleFlag, backtraceAtFlag,
verbosityFlag, vmoduleFlag, logdirFlag, backtraceAtFlag,
pprofFlag, pprofPortFlag,
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
}
@ -81,9 +85,17 @@ var Flags = []cli.Flag{
// Setup initializes profiling and logging based on the CLI flags.
// It should be called as early as possible in the program.
func Setup(ctx *cli.Context) error {
// logging
glog.CopyStandardLogTo("INFO")
if logDir := ctx.GlobalString(logdirFlag.Name); logDir != "" {
if err := Handler.SetLogDir(logDir); err != nil {
return err
}
glog.SetToStderr(false)
} else {
glog.SetToStderr(true)
}
glog.CopyStandardLogTo("INFO")
// profiling, tracing
runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name)