mirror of
https://github.com/mjl-/mox.git
synced 2025-07-14 03:34:37 +03:00
switch to slog.Logger for logging, for easier reuse of packages by external software
we don't want external software to include internal details like mlog. slog.Logger is/will be the standard. we still have mlog for its helper functions, and its handler that logs in concise logfmt used by mox. packages that are not meant for reuse still pass around mlog.Log for convenience. we use golang.org/x/exp/slog because we also support the previous Go toolchain version. with the next Go release, we'll switch to the builtin slog.
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/mjl-/mox/dns"
|
||||
"github.com/mjl-/mox/dnsbl"
|
||||
"github.com/mjl-/mox/mlog"
|
||||
)
|
||||
|
||||
var dnsblHealth = struct {
|
||||
@ -23,12 +24,12 @@ type dnsblStatus struct {
|
||||
}
|
||||
|
||||
// checkDNSBLHealth checks healthiness of DNSBL "zone", keeping the result cached for 4 hours.
|
||||
func checkDNSBLHealth(ctx context.Context, resolver dns.Resolver, zone dns.Domain) (rok bool) {
|
||||
func checkDNSBLHealth(ctx context.Context, log mlog.Log, resolver dns.Resolver, zone dns.Domain) (rok bool) {
|
||||
dnsblHealth.Lock()
|
||||
defer dnsblHealth.Unlock()
|
||||
status, ok := dnsblHealth.zones[zone]
|
||||
if !ok || time.Since(status.last) > 4*time.Hour {
|
||||
status.err = dnsbl.CheckHealth(ctx, resolver, zone)
|
||||
status.err = dnsbl.CheckHealth(ctx, log.Logger, resolver, zone)
|
||||
status.last = time.Now()
|
||||
dnsblHealth.zones[zone] = status
|
||||
}
|
||||
|
Reference in New Issue
Block a user