git » chasquid » commit d93d7ca

config: Quote strings when logging the configuration

author Alberto Bertogli
2023-12-02 14:56:54 UTC
committer Alberto Bertogli
2023-12-02 15:01:31 UTC
parent a0f09308ed2e29c1585e2bc3c7b7a26f5241008d

config: Quote strings when logging the configuration

When logging the configuration, we currently don't quote the string
values, which can make whitespace-induced problems difficult to identify
and troubleshoot.

This patch changes the formatting to always quote string values when
logging the configuration.

internal/config/config.go +9 -9

diff --git a/internal/config/config.go b/internal/config/config.go
index f994373..1de2353 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -133,23 +133,23 @@ func LogConfig(c *Config) {
 	log.Infof("Configuration:")
 	log.Infof("  Hostname: %q", c.Hostname)
 	log.Infof("  Max data size (MB): %d", c.MaxDataSizeMb)
-	log.Infof("  SMTP Addresses: %v", c.SmtpAddress)
-	log.Infof("  Submission Addresses: %v", c.SubmissionAddress)
-	log.Infof("  Submission+TLS Addresses: %v", c.SubmissionOverTlsAddress)
-	log.Infof("  Monitoring address: %s", c.MonitoringAddress)
-	log.Infof("  MDA: %s %v", c.MailDeliveryAgentBin, c.MailDeliveryAgentArgs)
-	log.Infof("  Data directory: %s", c.DataDir)
+	log.Infof("  SMTP Addresses: %q", c.SmtpAddress)
+	log.Infof("  Submission Addresses: %q", c.SubmissionAddress)
+	log.Infof("  Submission+TLS Addresses: %q", c.SubmissionOverTlsAddress)
+	log.Infof("  Monitoring address: %q", c.MonitoringAddress)
+	log.Infof("  MDA: %q %q", c.MailDeliveryAgentBin, c.MailDeliveryAgentArgs)
+	log.Infof("  Data directory: %q", c.DataDir)
 	if c.SuffixSeparators == nil {
 		log.Infof("  Suffix separators: nil")
 	} else {
-		log.Infof("  Suffix separators: %s", *c.SuffixSeparators)
+		log.Infof("  Suffix separators: %q", *c.SuffixSeparators)
 	}
 	if c.DropCharacters == nil {
 		log.Infof("  Drop characters: nil")
 	} else {
-		log.Infof("  Drop characters: %s", *c.DropCharacters)
+		log.Infof("  Drop characters: %q", *c.DropCharacters)
 	}
-	log.Infof("  Mail log: %s", c.MailLogPath)
+	log.Infof("  Mail log: %q", c.MailLogPath)
 	log.Infof("  Dovecot auth: %v (%q, %q)",
 		c.DovecotAuth, c.DovecotUserdbPath, c.DovecotClientPath)
 	log.Infof("  HAProxy incoming: %v", c.HaproxyIncoming)