From 977d4a5ee45ae546537324a3cfbf926de3bebc97 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Tue, 24 Oct 2023 09:51:17 -0500 Subject: [PATCH] Fix replica-without-db logger (#512) --- replica.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/replica.go b/replica.go index a26379a7..bf858836 100644 --- a/replica.go +++ b/replica.go @@ -99,7 +99,11 @@ func (r *Replica) Name() string { // Logger returns the DB sub-logger for this replica. func (r *Replica) Logger() *slog.Logger { - return r.db.Logger.With("replica", r.Name()) + logger := slog.Default() + if r.db != nil { + logger = r.db.Logger + } + return logger.With("replica", r.Name()) } // DB returns a reference to the database the replica is attached to, if any.