notify-mailer: improve log output (#5094)

One of the log lines describes the most frequent address corresponding
to a number of accounts, but it actually corresponds to a number of
lines in the input CSV.

Also, now that we escape newlines in log output, the dryRunMailer's
output looks messed up. Split the message body into lines and emit one
log message per line.
This commit is contained in:
Jacob Hoffman-Andrews 2020-09-17 09:56:24 -07:00 committed by GitHub
parent ef955a561a
commit 3bf6aa4aac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -125,7 +125,7 @@ func (m *mailer) run() error {
biggestAddress = k
}
}
m.log.Infof("Most frequent address %q had %d associated accounts", biggestAddress, biggest)
m.log.Infof("Most frequent address %q had %d associated lines", biggestAddress, biggest)
err = m.mailer.Connect()
if err != nil {

View File

@ -102,7 +102,9 @@ func (d dryRunClient) Data() (io.WriteCloser, error) {
}
func (d dryRunClient) Write(p []byte) (n int, err error) {
d.log.Debugf("data: %s", string(p))
for _, line := range strings.Split(string(p), "\n") {
d.log.Debugf("data: %s", line)
}
return len(p), nil
}