diff --git a/pkg/cluster/cluster_scan_options.go b/pkg/cluster/cluster_scan_options.go index 0f71516..8284e9f 100644 --- a/pkg/cluster/cluster_scan_options.go +++ b/pkg/cluster/cluster_scan_options.go @@ -6,7 +6,6 @@ import ( "darvaza.org/resolver" "darvaza.org/slog" - "darvaza.org/slog/handlers/discard" "github.com/hack-pad/hackpadfs/os" ) @@ -65,7 +64,7 @@ func WithResolver(h resolver.Resolver) ScanOption { func WithLogger(log slog.Logger) ScanOption { return func(m *Cluster, opt *ScanOptions) error { if log == nil { - log = discard.New() + log = DefaultLogger() } opt.Logger = log @@ -76,7 +75,7 @@ func WithLogger(log slog.Logger) ScanOption { func (m *Cluster) setDefaults(opt *ScanOptions) error { if m.resolver == nil { - h := resolver.NewCloudflareLookuper() + h := DefaultLookuper() if err := WithLookuper(h)(m, opt); err != nil { return err diff --git a/pkg/cluster/defaults.go b/pkg/cluster/defaults.go new file mode 100644 index 0000000..925b3d5 --- /dev/null +++ b/pkg/cluster/defaults.go @@ -0,0 +1,17 @@ +package cluster + +import ( + "darvaza.org/resolver" + "darvaza.org/slog" + "darvaza.org/slog/handlers/discard" +) + +// DefaultLogger returns a logger that doesn't log anything +func DefaultLogger() slog.Logger { + return discard.New() +} + +// DefaultLookuper returns a [resolver.Lookuper] using Cloudflare's 1.1.1.1 +func DefaultLookuper() resolver.Lookuper { + return resolver.NewCloudflareLookuper() +}