Skip to content

Commit 977d4a5

Browse files
authored
Fix replica-without-db logger (#512)
1 parent c81010e commit 977d4a5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

replica.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,11 @@ func (r *Replica) Name() string {
9999

100100
// Logger returns the DB sub-logger for this replica.
101101
func (r *Replica) Logger() *slog.Logger {
102-
return r.db.Logger.With("replica", r.Name())
102+
logger := slog.Default()
103+
if r.db != nil {
104+
logger = r.db.Logger
105+
}
106+
return logger.With("replica", r.Name())
103107
}
104108

105109
// DB returns a reference to the database the replica is attached to, if any.

0 commit comments

Comments
 (0)