consistently use lower-cased field names for logging lines

This commit is contained in:
Mechiel Lukkien 2023-02-25 12:37:59 +01:00
parent 0ede7f78c1
commit 26fcaa17f5
No known key found for this signature in database
7 changed files with 15 additions and 15 deletions

View file

@ -718,14 +718,14 @@ func (f *Filter) TrainDirs(hamDir, sentDir, spamDir string, hamFiles, sentFiles,
fields := []mlog.Pair{ fields := []mlog.Pair{
mlog.Field("hams", hams), mlog.Field("hams", hams),
mlog.Field("hamTime", tham), mlog.Field("hamtime", tham),
mlog.Field("hamMalformed", hamMalformed), mlog.Field("hammalformed", hamMalformed),
mlog.Field("sent", sent), mlog.Field("sent", sent),
mlog.Field("sentTime", tsent), mlog.Field("senttime", tsent),
mlog.Field("sentMalformed", sentMalformed), mlog.Field("sentmalformed", sentMalformed),
mlog.Field("spams", f.spams), mlog.Field("spams", f.spams),
mlog.Field("spamTime", tspam), mlog.Field("spamtime", tspam),
mlog.Field("spamMalformed", spamMalformed), mlog.Field("spammalformed", spamMalformed),
mlog.Field("dbsize", fmt.Sprintf("%.1fmb", float64(dbSize)/(1024*1024))), mlog.Field("dbsize", fmt.Sprintf("%.1fmb", float64(dbSize)/(1024*1024))),
mlog.Field("bloomsize", fmt.Sprintf("%.1fmb", float64(bloomSize)/(1024*1024))), mlog.Field("bloomsize", fmt.Sprintf("%.1fmb", float64(bloomSize)/(1024*1024))),
mlog.Field("bloom1ratio", fmt.Sprintf("%.4f", float64(f.bloom.Ones())/float64(len(f.bloom.Bytes())*8))), mlog.Field("bloom1ratio", fmt.Sprintf("%.4f", float64(f.bloom.Ones())/float64(len(f.bloom.Bytes())*8))),

View file

@ -442,7 +442,7 @@ func queueDelete(msgID int64) error {
// message, or updating the time for the next attempt. A DSN may be sent. // message, or updating the time for the next attempt. A DSN may be sent.
func deliver(resolver dns.Resolver, m Msg) { func deliver(resolver dns.Resolver, m Msg) {
cid := mox.Cid() cid := mox.Cid()
qlog := xlog.WithCid(cid).Fields(mlog.Field("from", m.Sender()), mlog.Field("recipient", m.Recipient()), mlog.Field("attempts", m.Attempts), mlog.Field("msgID", m.ID)) qlog := xlog.WithCid(cid).Fields(mlog.Field("from", m.Sender()), mlog.Field("recipient", m.Recipient()), mlog.Field("attempts", m.Attempts), mlog.Field("msgid", m.ID))
defer func() { defer func() {
deliveryResult <- formatIPDomain(m.RecipientDomain) deliveryResult <- formatIPDomain(m.RecipientDomain)
@ -492,7 +492,7 @@ func deliver(resolver dns.Resolver, m Msg) {
qup := bstore.QueryDB[Msg](queueDB) qup := bstore.QueryDB[Msg](queueDB)
qup.FilterID(m.ID) qup.FilterID(m.ID)
if _, err := qup.UpdateNonzero(Msg{LastError: errmsg, DialedIPs: m.DialedIPs}); err != nil { if _, err := qup.UpdateNonzero(Msg{LastError: errmsg, DialedIPs: m.DialedIPs}); err != nil {
qlog.Errorx("storing delivery error", err, mlog.Field("deliveryError", errmsg)) qlog.Errorx("storing delivery error", err, mlog.Field("deliveryerror", errmsg))
} }
if m.Attempts == 5 { if m.Attempts == 5 {
@ -705,7 +705,7 @@ func deliverHost(log *mlog.Log, resolver dns.Resolver, cid int64, host dns.IPDom
var deliveryResult string var deliveryResult string
defer func() { defer func() {
metricDeliveryHost.WithLabelValues(fmt.Sprintf("%d", m.Attempts), string(tlsMode), deliveryResult).Observe(float64(time.Since(start)) / float64(time.Second)) metricDeliveryHost.WithLabelValues(fmt.Sprintf("%d", m.Attempts), string(tlsMode), deliveryResult).Observe(float64(time.Since(start)) / float64(time.Second))
log.Debug("queue deliverhost result", mlog.Field("host", host), mlog.Field("attempt", m.Attempts), mlog.Field("tlsmode", tlsMode), mlog.Field("permanent", permanent), mlog.Field("badTLS", badTLS), mlog.Field("secodeOpt", secodeOpt), mlog.Field("errmsg", errmsg), mlog.Field("ok", ok), mlog.Field("duration", time.Since(start))) log.Debug("queue deliverhost result", mlog.Field("host", host), mlog.Field("attempt", m.Attempts), mlog.Field("tlsmode", tlsMode), mlog.Field("permanent", permanent), mlog.Field("badtls", badTLS), mlog.Field("secodeopt", secodeOpt), mlog.Field("errmsg", errmsg), mlog.Field("ok", ok), mlog.Field("duration", time.Since(start)))
}() }()
f, err := os.Open(m.MessagePath()) f, err := os.Open(m.MessagePath())

View file

@ -271,7 +271,7 @@ func analyze(ctx context.Context, log *mlog.Log, resolver dns.Resolver, d delive
} }
accept = contentProb <= threshold accept = contentProb <= threshold
junkSubjectpass = contentProb < threshold-0.2 junkSubjectpass = contentProb < threshold-0.2
log.Info("content analyzed", mlog.Field("accept", accept), mlog.Field("contentProb", contentProb), mlog.Field("subjectpass", junkSubjectpass)) log.Info("content analyzed", mlog.Field("accept", accept), mlog.Field("contentprob", contentProb), mlog.Field("subjectpass", junkSubjectpass))
} else if err != store.ErrNoJunkFilter { } else if err != store.ErrNoJunkFilter {
log.Errorx("open junkfilter", err) log.Errorx("open junkfilter", err)
return reject(smtp.C451LocalErr, smtp.SeSys3Other0, "error processing", err, reasonJunkFilterError) return reject(smtp.C451LocalErr, smtp.SeSys3Other0, "error processing", err, reasonJunkFilterError)

View file

@ -1874,7 +1874,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
}) })
switch receivedSPF.Result { switch receivedSPF.Result {
case spf.StatusPass: case spf.StatusPass:
c.log.Debug("spf pass", mlog.Field("ip", spfArgs.RemoteIP), mlog.Field("mailfromDomain", spfArgs.MailFromDomain.ASCII)) // todo: log the domain that was actually verified. c.log.Debug("spf pass", mlog.Field("ip", spfArgs.RemoteIP), mlog.Field("mailfromdomain", spfArgs.MailFromDomain.ASCII)) // todo: log the domain that was actually verified.
case spf.StatusFail: case spf.StatusFail:
if spfExpl != "" { if spfExpl != "" {
// Filter out potentially hostile text. ../rfc/7208:2529 // Filter out potentially hostile text. ../rfc/7208:2529
@ -2237,7 +2237,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
conf, _ := acc.Conf() conf, _ := acc.Conf()
if conf.RejectsMailbox != "" && messageID != "" { if conf.RejectsMailbox != "" && messageID != "" {
if err := acc.RejectsRemove(log, conf.RejectsMailbox, messageID); err != nil { if err := acc.RejectsRemove(log, conf.RejectsMailbox, messageID); err != nil {
log.Errorx("removing message from rejects mailbox", err, mlog.Field("messageID", messageID)) log.Errorx("removing message from rejects mailbox", err, mlog.Field("messageid", messageID))
} }
} }
}) })

View file

@ -291,7 +291,7 @@ func evaluate(ctx context.Context, record *Record, resolver dns.Resolver, args A
log := xlog.WithContext(ctx) log := xlog.WithContext(ctx)
start := time.Now() start := time.Now()
defer func() { defer func() {
log.Debugx("spf evaluate result", rerr, mlog.Field("dnsrequests", *args.dnsRequests), mlog.Field("voidLookups", *args.voidLookups), mlog.Field("domain", args.domain), mlog.Field("status", rstatus), mlog.Field("mechanism", mechanism), mlog.Field("explanation", rexplanation), mlog.Field("duration", time.Since(start))) log.Debugx("spf evaluate result", rerr, mlog.Field("dnsrequests", *args.dnsRequests), mlog.Field("voidlookups", *args.voidLookups), mlog.Field("domain", args.domain), mlog.Field("status", rstatus), mlog.Field("mechanism", mechanism), mlog.Field("explanation", rexplanation), mlog.Field("duration", time.Since(start)))
}() }()
resolver = dns.WithPackage(resolver, "spf") resolver = dns.WithPackage(resolver, "spf")

View file

@ -92,7 +92,7 @@ func (a *Account) RetrainMessage(log *mlog.Log, tx *bstore.Tx, jf *junk.Filter,
return nil return nil
} }
log.Debug("updating junk filter", mlog.Field("untrain", untrain), mlog.Field("untrainJunk", untrainJunk), mlog.Field("train", train), mlog.Field("trainJunk", trainJunk)) log.Debug("updating junk filter", mlog.Field("untrain", untrain), mlog.Field("untrainjunk", untrainJunk), mlog.Field("train", train), mlog.Field("trainjunk", trainJunk))
mr := a.MessageReader(*m) mr := a.MessageReader(*m)
defer func() { defer func() {

View file

@ -185,7 +185,7 @@ func Check(ctx context.Context, resolver dns.Resolver, domain dns.Domain, lastKn
log := xlog.WithContext(ctx) log := xlog.WithContext(ctx)
start := time.Now() start := time.Now()
defer func() { defer func() {
log.Debugx("updates check result", rerr, mlog.Field("domain", domain), mlog.Field("lastKnown", lastKnown), mlog.Field("changelogbaseurl", changelogBaseURL), mlog.Field("version", rversion), mlog.Field("record", rrecord), mlog.Field("duration", time.Since(start))) log.Debugx("updates check result", rerr, mlog.Field("domain", domain), mlog.Field("lastknown", lastKnown), mlog.Field("changelogbaseurl", changelogBaseURL), mlog.Field("version", rversion), mlog.Field("record", rrecord), mlog.Field("duration", time.Since(start)))
}() }()
latest, record, err := Lookup(ctx, resolver, domain) latest, record, err := Lookup(ctx, resolver, domain)