Skip to content

Commit

Permalink
Changes RootLogger refs to Logger
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmy Moore <jamesmoore@loopholelabs.io>
  • Loading branch information
jimmyaxod committed Nov 25, 2024
1 parent a450377 commit 1597a5b
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/expose/nbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ var DefaultConfig = &Config{
}

type Config struct {
Logger types.RootLogger
Logger types.Logger
NumConnections int
Timeout time.Duration
BlockSize uint64
AsyncReads bool
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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/expose/nbd_dispatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ type Response struct {
}

type Dispatch struct {
logger types.RootLogger
logger types.Logger
dev string
ctx context.Context
asyncReads bool
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/migrator/migrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

type Config struct {
Logger types.RootLogger
Logger types.Logger
BlockSize int
LockerHandler func()
UnlockerHandler func()
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/migrator/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/modules/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type Logger struct {
storage.ProviderWithEvents
prov storage.Provider
prefix string
log types.RootLogger
log types.Logger
enabled atomic.Bool
}

Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/waitingcache/waiting_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
*
*/
type WaitingCache struct {
logger types.RootLogger
logger types.Logger
uuid uuid.UUID
prov storage.Provider
local *Local
Expand All @@ -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,
Expand Down

0 comments on commit 1597a5b

Please sign in to comment.