Fix replica-without-db logger (#512)

This commit is contained in:
Ben Johnson
2023-10-24 09:51:17 -05:00
committed by GitHub
parent c81010e7ab
commit 977d4a5ee4

View File

@@ -99,7 +99,11 @@ func (r *Replica) Name() string {
// Logger returns the DB sub-logger for this replica. // Logger returns the DB sub-logger for this replica.
func (r *Replica) Logger() *slog.Logger { 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. // DB returns a reference to the database the replica is attached to, if any.