Skip to content

Commit

Permalink
Fix replica-without-db logger (#512)
Browse files Browse the repository at this point in the history
  • Loading branch information
benbjohnson authored Oct 24, 2023
1 parent c81010e commit 977d4a5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion replica.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 977d4a5

Please sign in to comment.