Add log level to redis and memory backends (#50)

This commit is contained in:
Adriano Caloiaro 2023-05-02 20:46:04 -06:00 committed by GitHub
parent 43a0a133f2
commit d68db7b442
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View file

@ -51,7 +51,6 @@ func Backend(ctx context.Context, opts ...config.Option) (backend types.Backend,
handlers: &sync.Map{},
futureJobs: &sync.Map{},
fingerprints: &sync.Map{},
logger: slog.New(slog.NewTextHandler(os.Stdout)),
jobCount: 0,
cancelFuncs: []context.CancelFunc{},
}
@ -61,6 +60,8 @@ func Backend(ctx context.Context, opts ...config.Option) (backend types.Backend,
opt(mb.config)
}
mb.logger = slog.New(slog.HandlerOptions{Level: mb.config.LogLevel}.NewTextHandler(os.Stdout))
backend = mb
return

View file

@ -76,7 +76,6 @@ func Backend(ctx context.Context, opts ...config.Option) (backend types.Backend,
b := &redisBackend{
config: config.New(),
mu: &sync.Mutex{},
logger: slog.New(slog.NewTextHandler(os.Stdout)),
taskProvider: NewMemoryTaskConfigProvider(),
}
@ -84,6 +83,8 @@ func Backend(ctx context.Context, opts ...config.Option) (backend types.Backend,
opt(b.config)
}
b.logger = slog.New(slog.HandlerOptions{Level: b.config.LogLevel}.NewTextHandler(os.Stdout))
if b.config.ConnectionString == "" {
err = ErrInvalidAddr
return