Merge pull request #791 from cosmos/bucky/log

add log_level flag
This commit is contained in:
Ethan Buchman 2018-04-05 14:15:35 +03:00 committed by GitHub
commit e0d043b342
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 6 deletions

View File

@ -2,7 +2,7 @@ PACKAGES=$(shell go list ./... | grep -v '/vendor/')
COMMIT_HASH := $(shell git rev-parse --short HEAD)
BUILD_FLAGS = -ldflags "-X github.com/cosmos/cosmos-sdk/version.GitCommit=${COMMIT_HASH}"
all: check_tools get_vendor_deps build test
all: check_tools get_vendor_deps build build_examples test
########################################
### CI

View File

@ -17,7 +17,7 @@ import (
// rootCmd is the entry point for this binary
var (
context = server.NewContext(nil, nil)
context = server.NewDefaultContext()
rootCmd = &cobra.Command{
Use: "gaiad",
Short: "Gaia Daemon (server)",

View File

@ -15,9 +15,9 @@ import (
"github.com/cosmos/cosmos-sdk/server"
)
// basecoindCmd is the entry point for this binary
// rootCmd is the entry point for this binary
var (
context = server.NewContext(nil, nil)
context = server.NewDefaultContext()
rootCmd = &cobra.Command{
Use: "basecoind",
Short: "Basecoin Daemon (server)",

View File

@ -17,9 +17,9 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
)
// democoindCmd is the entry point for this binary
// rootCmd is the entry point for this binary
var (
context = server.NewContext(nil, nil)
context = server.NewDefaultContext()
rootCmd = &cobra.Command{
Use: "democoind",
Short: "Democoin Daemon (server)",

View File

@ -19,6 +19,13 @@ type Context struct {
Logger log.Logger
}
func NewDefaultContext() *Context {
return NewContext(
cfg.DefaultConfig(),
log.NewTMLogger(log.NewSyncWriter(os.Stdout)),
)
}
func NewContext(config *cfg.Config, logger log.Logger) *Context {
return &Context{config, logger}
}
@ -57,6 +64,8 @@ func AddCommands(
appState GenAppState, appCreator AppCreator,
context *Context) {
rootCmd.PersistentFlags().String("log_level", context.Config.LogLevel, "Log level")
rootCmd.AddCommand(
InitCmd(appState, context),
StartCmd(appCreator, context),