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

View File

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

View File

@ -40,6 +40,7 @@ import (
"github.com/ethereum/go-ethereum/eth" "github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/internal/debug"
"github.com/ethereum/go-ethereum/les" "github.com/ethereum/go-ethereum/les"
"github.com/ethereum/go-ethereum/light" "github.com/ethereum/go-ethereum/light"
"github.com/ethereum/go-ethereum/logger" "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 // MustMakeDataDir retrieves the currently requested data directory, terminating
// if none (or the empty string) is specified. If the node is starting a testnet, // 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. // the a subdirectory of the specified datadir will be used.

View File

@ -84,6 +84,12 @@ func (*HandlerT) GcStats() *debug.GCStats {
return s 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 // CpuProfile turns on CPU profiling for nsec seconds and writes
// profile data to file. // profile data to file.
func (h *HandlerT) CpuProfile(file string, nsec uint) error { 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\")", Usage: "Request a stack trace at a specific logging statement (e.g. \"block.go:271\")",
Value: glog.GetTraceLocation(), Value: glog.GetTraceLocation(),
} }
logdirFlag = cli.StringFlag{
Name: "logdir",
Usage: "Request that glog use the specified log dir location",
}
pprofFlag = cli.BoolFlag{ pprofFlag = cli.BoolFlag{
Name: "pprof", Name: "pprof",
Usage: "Enable the pprof HTTP server", Usage: "Enable the pprof HTTP server",
@ -73,7 +77,7 @@ var (
// Flags holds all command-line flags required for debugging. // Flags holds all command-line flags required for debugging.
var Flags = []cli.Flag{ var Flags = []cli.Flag{
verbosityFlag, vmoduleFlag, backtraceAtFlag, verbosityFlag, vmoduleFlag, logdirFlag, backtraceAtFlag,
pprofFlag, pprofPortFlag, pprofFlag, pprofPortFlag,
memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag, memprofilerateFlag, blockprofilerateFlag, cpuprofileFlag, traceFlag,
} }
@ -81,9 +85,17 @@ var Flags = []cli.Flag{
// Setup initializes profiling and logging based on the CLI flags. // Setup initializes profiling and logging based on the CLI flags.
// It should be called as early as possible in the program. // It should be called as early as possible in the program.
func Setup(ctx *cli.Context) error { func Setup(ctx *cli.Context) error {
// logging // logging
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") glog.CopyStandardLogTo("INFO")
glog.SetToStderr(true)
// profiling, tracing // profiling, tracing
runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name) runtime.MemProfileRate = ctx.GlobalInt(memprofilerateFlag.Name)