This repository has been archived by the owner on Nov 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 188
log: support change the level of etcd for debugging #992
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -439,17 +439,22 @@ func parseURLs(s string) ([]url.URL, error) { | |||
return urls, nil | ||||
} | ||||
|
||||
func genEmbedEtcdConfigWithLogger() *embed.Config { | ||||
func genEmbedEtcdConfigWithLogger(logLevel string) *embed.Config { | ||||
cfg := embed.NewConfig() | ||||
cfg.EnableGRPCGateway = true // enable gRPC gateway for the internal etcd. | ||||
|
||||
// use zap as the logger for embed etcd | ||||
// NOTE: `genEmbedEtcdConfig` can only be called after logger initialized. | ||||
// NOTE: if using zap logger for etcd, must build it before any concurrent gRPC calls, | ||||
// otherwise, DATA RACE occur in NewZapCoreLoggerBuilder and gRPC. | ||||
// NOTE: we can only increase the log level for the clone logger but not decrease. | ||||
logger := log.L().WithFields(zap.String("component", "embed etcd")).WithOptions(zap.IncreaseLevel(zap.ErrorLevel)) | ||||
cfg.ZapLoggerBuilder = embed.NewZapCoreLoggerBuilder(logger, logger.Core(), log.Props().Syncer) // use global app props. | ||||
logger := log.L().WithFields(zap.String("component", "embed etcd")) | ||||
// if logLevel is info, set etcd log level to WARN to reduce log | ||||
if strings.ToLower(logLevel) == "info" { | ||||
log.L().Info("Set log level of etcd to `warn`, if you want to log more message about etcd, change log-level to `debug` in master configuration file") | ||||
logger.Logger = logger.WithOptions(zap.IncreaseLevel(zap.WarnLevel)) | ||||
} | ||||
|
||||
cfg.ZapLoggerBuilder = embed.NewZapCoreLoggerBuilder(logger.Logger, logger.Core(), log.Props().Syncer) // use global app props. | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure why change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. type of logger now is log.Logger after Line 451 in 7de7bb4
|
||||
cfg.Logger = "zap" | ||||
|
||||
// TODO: we run ZapLoggerBuilder to set SetLoggerV2 before we do some etcd operations | ||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's log this change to tell user. and "debug" maybe a level lower than "info"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add log in 6d12af4
user can use debug level to see more log about etcd.