From 516d449ed7d6ca1f63277f8be9c5375dafef98d1 Mon Sep 17 00:00:00 2001 From: "o.omahony" Date: Mon, 13 Mar 2023 17:54:55 +0000 Subject: [PATCH] remove fields from trace logging --- src/core/nginx.go | 14 +++++++++++++- .../github.com/nginx/agent/v2/src/core/nginx.go | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/core/nginx.go b/src/core/nginx.go index 7a76e74cd..6791d8d63 100644 --- a/src/core/nginx.go +++ b/src/core/nginx.go @@ -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() + } details, ok := n.nginxDetailsMap[config.ConfigData.NginxId] if !ok || details == nil { return nil, fmt.Errorf("NGINX instance %s not found", config.ConfigData.NginxId) diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go index 7a76e74cd..6791d8d63 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go @@ -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() + } details, ok := n.nginxDetailsMap[config.ConfigData.NginxId] if !ok || details == nil { return nil, fmt.Errorf("NGINX instance %s not found", config.ConfigData.NginxId)