Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove fields from trace logging #251

Merged
merged 1 commit into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/core/nginx.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,19 @@ func hasConfPath(files []*proto.File, confPath string) bool {
}

func (n *NginxBinaryType) WriteConfig(config *proto.NginxConfig) (*sdk.ConfigApply, error) {
log.Tracef("Writing config: %+v\n", config)
if log.IsLevelEnabled(log.TraceLevel) {
jsonLogger := log.New()
jsonLogger.SetFormatter(&log.JSONFormatter{})
jsonLogger.WithFields(log.Fields{
"access_logs": config.AccessLogs,
"error_logs": config.ErrorLogs,
"directory_map": config.DirectoryMap,
"config_contents": config.Zconfig,
"config_data": config.ConfigData,
"action": config.Action,
}).Trace("Writing config")
defer jsonLogger.Writer().Close()
Copy link
Contributor

@Dean-Coakley Dean-Coakley Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's slightly preferred to close the writer as soon as possible(Optional)

Suggested change
defer jsonLogger.Writer().Close()
jsonLogger.Writer().Close()

}
details, ok := n.nginxDetailsMap[config.ConfigData.NginxId]
if !ok || details == nil {
return nil, fmt.Errorf("NGINX instance %s not found", config.ConfigData.NginxId)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.