Skip to content

Commit

Permalink
fix enabling colorized output by default
Browse files Browse the repository at this point in the history
  • Loading branch information
tinoh9 authored and omerfirmak committed May 12, 2023
1 parent 677c3d4 commit 663e24a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cmd/juno/juno.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
defaultRPCPort = uint16(6060)
defaultDBPath = ""
defaultPprof = false
defaultColor = false
defaultColor = true

configFlagUsage = "The yaml configuration file."
logLevelFlagUsage = "Options: debug, info, warn, error."
Expand All @@ -46,7 +46,7 @@ const (
dbPathUsage = "Location of the database files."
networkUsage = "Options: mainnet, goerli, goerli2, integration."
pprofUsage = "Enables the pprof server and listens on port 9080."
colorUsage = "Enables colorized outputs (ANSI Escape Codes)."
colorUsage = "Uses --color=false command to disable colorized outputs (ANSI Escape Codes)."
)

var Version string
Expand Down
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func makeHTTP(port uint16, rpcHandler *rpc.Handler, log utils.SimpleLogger) *jso
func (n *Node) Run(ctx context.Context) {
n.log.Infow("Starting Juno...", "config", fmt.Sprintf("%+v", *n.cfg))

dbLog, err := utils.NewZapLogger(utils.ERROR, false)
dbLog, err := utils.NewZapLogger(utils.ERROR, n.cfg.Color)
if err != nil {
n.log.Errorw("Error creating DB logger", "err", err)
return
Expand Down
5 changes: 2 additions & 3 deletions utils/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,8 @@ func NewNopZapLogger() *ZapLogger {
func NewZapLogger(logLevel LogLevel, color bool) (*ZapLogger, error) {
config := zap.NewProductionConfig()
config.Encoding = "console"
if color {
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
} else {
config.EncoderConfig.EncodeLevel = zapcore.CapitalColorLevelEncoder
if !color {
config.EncoderConfig.EncodeLevel = zapcore.CapitalLevelEncoder
}
config.EncoderConfig.EncodeTime = func(t time.Time, enc zapcore.PrimitiveArrayEncoder) {
Expand Down

0 comments on commit 663e24a

Please sign in to comment.