mirror of
https://github.com/percona/percona-toolkit.git
synced 2025-09-19 18:34:59 +00:00
pt-galera-log-explainer: fix debug log formatting mismatch
"extrator" log was not using the same output format as the rest beacuse it was initialized before main()
This commit is contained in:
@@ -12,13 +12,14 @@ import (
|
|||||||
"github.com/percona/percona-toolkit/src/go/pt-galera-log-explainer/types"
|
"github.com/percona/percona-toolkit/src/go/pt-galera-log-explainer/types"
|
||||||
"github.com/percona/percona-toolkit/src/go/pt-galera-log-explainer/utils"
|
"github.com/percona/percona-toolkit/src/go/pt-galera-log-explainer/utils"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var logger = log.With().Str("component", "extractor").Logger()
|
var logger zerolog.Logger
|
||||||
|
|
||||||
func init() {
|
|
||||||
|
|
||||||
|
func initComponentLogger() {
|
||||||
|
logger = log.With().Str("component", "extractor").Logger()
|
||||||
if CLI.Since != nil {
|
if CLI.Since != nil {
|
||||||
logger = logger.With().Time("since", *CLI.Since).Logger()
|
logger = logger.With().Time("since", *CLI.Since).Logger()
|
||||||
}
|
}
|
||||||
|
@@ -62,6 +62,7 @@ func main() {
|
|||||||
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
||||||
zerolog.SetGlobalLevel(zerolog.InfoLevel)
|
zerolog.SetGlobalLevel(zerolog.InfoLevel)
|
||||||
log.Logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr, NoColor: CLI.NoColor, FormatTimestamp: func(_ interface{}) string { return "" }})
|
log.Logger = zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr, NoColor: CLI.NoColor, FormatTimestamp: func(_ interface{}) string { return "" }})
|
||||||
|
initComponentLogger()
|
||||||
if CLI.Verbosity == types.Debug {
|
if CLI.Verbosity == types.Debug {
|
||||||
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user