mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 13:44: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:
@ -47,7 +47,7 @@ func ipdomains(s ...string) (l []dns.IPDomain) {
|
||||
// exist or has temporary error.
|
||||
func TestGatherDestinations(t *testing.T) {
|
||||
ctxbg := context.Background()
|
||||
log := mlog.New("smtpclient")
|
||||
log := mlog.New("smtpclient", nil)
|
||||
|
||||
resolver := dns.MockResolver{
|
||||
MX: map[string][]*net.MX{
|
||||
@ -89,7 +89,7 @@ func TestGatherDestinations(t *testing.T) {
|
||||
test := func(ipd dns.IPDomain, expHosts []dns.IPDomain, expDomain dns.Domain, expPerm, expAuthic, expExpAuthic bool, expErr error) {
|
||||
t.Helper()
|
||||
|
||||
_, authic, authicExp, ed, hosts, perm, err := GatherDestinations(ctxbg, log, resolver, ipd)
|
||||
_, authic, authicExp, ed, hosts, perm, err := GatherDestinations(ctxbg, log.Logger, resolver, ipd)
|
||||
if (err == nil) != (expErr == nil) || err != nil && !errors.Is(err, expErr) {
|
||||
// todo: could also check the individual errors? code currently does not have structured errors.
|
||||
t.Fatalf("gather hosts: %v, expected %v", err, expErr)
|
||||
@ -134,7 +134,7 @@ func TestGatherDestinations(t *testing.T) {
|
||||
|
||||
func TestGatherIPs(t *testing.T) {
|
||||
ctxbg := context.Background()
|
||||
log := mlog.New("smtpclient")
|
||||
log := mlog.New("smtpclient", nil)
|
||||
|
||||
resolver := dns.MockResolver{
|
||||
A: map[string][]string{
|
||||
@ -164,7 +164,7 @@ func TestGatherIPs(t *testing.T) {
|
||||
test := func(host dns.IPDomain, expAuthic, expAuthicExp bool, expHostExp dns.Domain, expIPs []net.IP, expErr any) {
|
||||
t.Helper()
|
||||
|
||||
authic, authicExp, hostExp, ips, _, err := GatherIPs(ctxbg, log, resolver, host, nil)
|
||||
authic, authicExp, hostExp, ips, _, err := GatherIPs(ctxbg, log.Logger, resolver, host, nil)
|
||||
if (err == nil) != (expErr == nil) || err != nil && !(errors.Is(err, expErr.(error)) || errors.As(err, &expErr)) {
|
||||
// todo: could also check the individual errors?
|
||||
t.Fatalf("gather hosts: %v, expected %v", err, expErr)
|
||||
@ -207,7 +207,7 @@ func TestGatherIPs(t *testing.T) {
|
||||
|
||||
func TestGatherTLSA(t *testing.T) {
|
||||
ctxbg := context.Background()
|
||||
log := mlog.New("smtpclient")
|
||||
log := mlog.New("smtpclient", nil)
|
||||
|
||||
record := func(usage, selector, matchType uint8) adns.TLSA {
|
||||
return adns.TLSA{
|
||||
@ -253,7 +253,7 @@ func TestGatherTLSA(t *testing.T) {
|
||||
test := func(host dns.Domain, expandedAuthentic bool, expandedHost dns.Domain, expDANERequired bool, expRecords []adns.TLSA, expBaseDom dns.Domain, expErr any) {
|
||||
t.Helper()
|
||||
|
||||
daneReq, records, baseDom, err := GatherTLSA(ctxbg, log, resolver, host, expandedAuthentic, expandedHost)
|
||||
daneReq, records, baseDom, err := GatherTLSA(ctxbg, log.Logger, resolver, host, expandedAuthentic, expandedHost)
|
||||
if (err == nil) != (expErr == nil) || err != nil && !(errors.Is(err, expErr.(error)) || errors.As(err, &expErr)) {
|
||||
// todo: could also check the individual errors?
|
||||
t.Fatalf("gather tlsa: %v, expected %v", err, expErr)
|
||||
|
Reference in New Issue
Block a user