diff --git a/server/storage/backend/backend.go b/server/storage/backend/backend.go index e7b951ee7e6..7aa4f846987 100644 --- a/server/storage/backend/backend.go +++ b/server/storage/backend/backend.go @@ -180,6 +180,7 @@ func newBackend(bcfg BackendConfig) *backend { bopts.NoSync = bcfg.UnsafeNoFsync bopts.NoGrowSync = bcfg.UnsafeNoFsync bopts.Mlock = bcfg.Mlock + bopts.Logger = newBoltLoggerZap(bcfg) db, err := bolt.Open(bcfg.Path, 0600, bopts) if err != nil { @@ -659,3 +660,20 @@ func (s *snapshot) Close() error { <-s.donec return s.Tx.Rollback() } + +func newBoltLoggerZap(bcfg BackendConfig) bolt.Logger { + lg := bcfg.Logger.Named("bbolt") + return &zapBoltLogger{lg.WithOptions(zap.AddCallerSkip(1)).Sugar()} +} + +type zapBoltLogger struct { + *zap.SugaredLogger +} + +func (zl *zapBoltLogger) Warning(args ...any) { + zl.SugaredLogger.Warn(args...) +} + +func (zl *zapBoltLogger) Warningf(format string, args ...any) { + zl.SugaredLogger.Warnf(format, args...) +}