logger: refactor Tendermint logger by using zerolog (#6534)

This commit is contained in:
Aleksandr Bezobchuk
2021-06-07 08:30:48 -04:00
committed by GitHub
parent b28887e839
commit 3635c7a382
43 changed files with 316 additions and 1363 deletions
+8 -8
View File
@@ -8,6 +8,8 @@ import (
"os"
"path/filepath"
"time"
"github.com/tendermint/tendermint/libs/log"
)
const (
@@ -16,11 +18,6 @@ const (
// FuzzModeDelay is a mode in which we randomly sleep
FuzzModeDelay
// LogFormatPlain is a format for colored text
LogFormatPlain = "plain"
// LogFormatJSON is a format for json output
LogFormatJSON = "json"
// DefaultLogLevel defines a default log level as INFO.
DefaultLogLevel = "info"
@@ -276,7 +273,7 @@ func DefaultBaseConfig() BaseConfig {
ProxyApp: "tcp://127.0.0.1:26658",
ABCI: "socket",
LogLevel: DefaultLogLevel,
LogFormat: LogFormatPlain,
LogFormat: log.LogFormatPlain,
FastSyncMode: true,
FilterPeers: false,
DBBackend: "goleveldb",
@@ -331,17 +328,20 @@ func (cfg Config) ArePrivValidatorClientSecurityOptionsPresent() bool {
// returns an error if any check fails.
func (cfg BaseConfig) ValidateBasic() error {
switch cfg.LogFormat {
case LogFormatPlain, LogFormatJSON:
case log.LogFormatJSON, log.LogFormatText, log.LogFormatPlain:
default:
return errors.New("unknown log format (must be 'plain' or 'json')")
return errors.New("unknown log format (must be 'plain', 'text' or 'json')")
}
switch cfg.Mode {
case ModeFull, ModeValidator, ModeSeed:
case "":
return errors.New("no mode has been set")
default:
return fmt.Errorf("unknown mode: %v", cfg.Mode)
}
return nil
}