diff --git a/cmd/serve.go b/cmd/serve.go index 9ccdf3e5..699a3331 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -163,7 +163,7 @@ func runServe(_ *cobra.Command, _ []string) { shutdownEverything(log) } -func shutdownEverything(_ types.RootLogger) { +func shutdownEverything(_ types.Logger) { // first unlock everything fmt.Printf("Unlocking devices...\n") for _, i := range srcStorage { @@ -180,7 +180,7 @@ func shutdownEverything(_ types.RootLogger) { } } -func setupStorageDevice(conf *config.DeviceSchema, log types.RootLogger) (*storageInfo, error) { +func setupStorageDevice(conf *config.DeviceSchema, log types.Logger) (*storageInfo, error) { source, ex, err := device.NewDeviceWithLogging(conf, log) if err != nil { return nil, err @@ -234,7 +234,7 @@ func setupStorageDevice(conf *config.DeviceSchema, log types.RootLogger) (*stora } // Migrate a device -func migrateDevice(log types.RootLogger, devID uint32, name string, +func migrateDevice(log types.Logger, devID uint32, name string, pro protocol.Protocol, sinfo *storageInfo) error { size := sinfo.lockable.Size() diff --git a/pkg/storage/device/device.go b/pkg/storage/device/device.go index e53c7e79..86ce755e 100644 --- a/pkg/storage/device/device.go +++ b/pkg/storage/device/device.go @@ -41,7 +41,7 @@ func NewDevices(ds []*config.DeviceSchema) (map[string]*Device, error) { return NewDevicesWithLogging(ds, nil) } -func NewDevicesWithLogging(ds []*config.DeviceSchema, log types.RootLogger) (map[string]*Device, error) { +func NewDevicesWithLogging(ds []*config.DeviceSchema, log types.Logger) (map[string]*Device, error) { devices := make(map[string]*Device) for _, c := range ds { dev, ex, err := NewDeviceWithLogging(c, log) @@ -67,7 +67,7 @@ func NewDevice(ds *config.DeviceSchema) (storage.Provider, storage.ExposedStorag return NewDeviceWithLogging(ds, nil) } -func NewDeviceWithLogging(ds *config.DeviceSchema, log types.RootLogger) (storage.Provider, storage.ExposedStorage, error) { +func NewDeviceWithLogging(ds *config.DeviceSchema, log types.Logger) (storage.Provider, storage.ExposedStorage, error) { if log != nil { log.Debug().Str("name", ds.Name).Msg("creating new device") } diff --git a/pkg/storage/expose/nbd.go b/pkg/storage/expose/nbd.go index 7f3379fd..654b19a9 100644 --- a/pkg/storage/expose/nbd.go +++ b/pkg/storage/expose/nbd.go @@ -30,7 +30,7 @@ var DefaultConfig = &Config{ } type Config struct { - Logger types.RootLogger + Logger types.Logger NumConnections int Timeout time.Duration BlockSize uint64 @@ -38,7 +38,7 @@ type Config struct { AsyncWrites bool } -func (c *Config) WithLogger(l types.RootLogger) *Config { +func (c *Config) WithLogger(l types.Logger) *Config { return &Config{Logger: l, NumConnections: c.NumConnections, Timeout: c.Timeout, diff --git a/pkg/storage/expose/nbd_dispatch.go b/pkg/storage/expose/nbd_dispatch.go index d5b15cff..d6064f89 100644 --- a/pkg/storage/expose/nbd_dispatch.go +++ b/pkg/storage/expose/nbd_dispatch.go @@ -63,7 +63,7 @@ type Response struct { } type Dispatch struct { - logger types.RootLogger + logger types.Logger dev string ctx context.Context asyncReads bool @@ -78,7 +78,7 @@ type Dispatch struct { metricPacketsOut uint64 } -func NewDispatch(ctx context.Context, name string, logger types.RootLogger, fp io.ReadWriteCloser, prov storage.Provider) *Dispatch { +func NewDispatch(ctx context.Context, name string, logger types.Logger, fp io.ReadWriteCloser, prov storage.Provider) *Dispatch { d := &Dispatch{ logger: logger, diff --git a/pkg/storage/migrator/migrator.go b/pkg/storage/migrator/migrator.go index e2896c84..aea5dd9e 100644 --- a/pkg/storage/migrator/migrator.go +++ b/pkg/storage/migrator/migrator.go @@ -19,7 +19,7 @@ import ( ) type Config struct { - Logger types.RootLogger + Logger types.Logger BlockSize int LockerHandler func() UnlockerHandler func() @@ -74,7 +74,7 @@ type MigrationProgress struct { type Migrator struct { uuid uuid.UUID - logger types.RootLogger + logger types.Logger sourceTracker storage.TrackingProvider // Tracks writes so we know which are dirty sourceMapped *modules.MappedStorage destWriteWithMap func([]byte, int64, map[uint64]uint64) (int, error) diff --git a/pkg/storage/migrator/sync.go b/pkg/storage/migrator/sync.go index 10a9fba6..672df82f 100644 --- a/pkg/storage/migrator/sync.go +++ b/pkg/storage/migrator/sync.go @@ -14,7 +14,7 @@ import ( ) type SyncConfig struct { - Logger types.RootLogger + Logger types.Logger Name string Tracker *dirtytracker.Remote // A dirty block tracker Lockable storage.LockableProvider // Lockable diff --git a/pkg/storage/modules/logger.go b/pkg/storage/modules/logger.go index db99735b..76735e98 100644 --- a/pkg/storage/modules/logger.go +++ b/pkg/storage/modules/logger.go @@ -11,7 +11,7 @@ type Logger struct { storage.ProviderWithEvents prov storage.Provider prefix string - log types.RootLogger + log types.Logger enabled atomic.Bool } @@ -21,7 +21,7 @@ func (i *Logger) SendSiloEvent(eventType storage.EventType, eventData storage.Ev return append(data, storage.SendSiloEvent(i.prov, eventType, eventData)...) } -func NewLogger(prov storage.Provider, prefix string, log types.RootLogger) *Logger { +func NewLogger(prov storage.Provider, prefix string, log types.Logger) *Logger { l := &Logger{ prov: prov, log: log, diff --git a/pkg/storage/waitingcache/waiting_cache.go b/pkg/storage/waitingcache/waiting_cache.go index 38a7025f..fb72d720 100644 --- a/pkg/storage/waitingcache/waiting_cache.go +++ b/pkg/storage/waitingcache/waiting_cache.go @@ -16,7 +16,7 @@ import ( * */ type WaitingCache struct { - logger types.RootLogger + logger types.Logger uuid uuid.UUID prov storage.Provider local *Local @@ -33,7 +33,7 @@ func NewWaitingCache(prov storage.Provider, blockSize int) (*Local, *Remote) { return NewWaitingCacheWithLogger(prov, blockSize, nil) } -func NewWaitingCacheWithLogger(prov storage.Provider, blockSize int, log types.RootLogger) (*Local, *Remote) { +func NewWaitingCacheWithLogger(prov storage.Provider, blockSize int, log types.Logger) (*Local, *Remote) { numBlocks := (int(prov.Size()) + blockSize - 1) / blockSize wc := &WaitingCache{ logger: log,