feat(GODT-3199): add package log field.

This commit is contained in:
Jakub
2024-02-26 14:16:50 +01:00
parent bf3c90b8e9
commit c9b6cc162b
17 changed files with 129 additions and 118 deletions

View File

@ -29,6 +29,8 @@ import (
"github.com/sirupsen/logrus"
)
var logSMTP = logrus.WithField("pkg", "server/smtp") //nolint:gochecknoglobals
type SMTPSettingsProvider interface {
TLSConfig() *tls.Config
Log() bool
@ -39,7 +41,7 @@ type SMTPSettingsProvider interface {
}
func newSMTPServer(accounts *smtpservice.Accounts, settings SMTPSettingsProvider) *smtp.Server {
logrus.WithField("logSMTP", settings.Log()).Info("Creating SMTP server")
logSMTP.WithField("logSMTP", settings.Log()).Info("Creating SMTP server")
smtpServer := smtp.NewServer(smtpservice.NewBackend(accounts, settings.Identifier()))
@ -57,10 +59,9 @@ func newSMTPServer(accounts *smtpservice.Accounts, settings SMTPSettingsProvider
})
if settings.Log() {
log := logrus.WithField("protocol", "SMTP")
log.Warning("================================================")
log.Warning("THIS LOG WILL CONTAIN **DECRYPTED** MESSAGE DATA")
log.Warning("================================================")
logSMTP.Warning("================================================")
logSMTP.Warning("THIS LOG WILL CONTAIN **DECRYPTED** MESSAGE DATA")
logSMTP.Warning("================================================")
smtpServer.Debug = logging.NewSMTPDebugLogger()
}