feat(actions): improve errors and logs (#340)

This commit is contained in:
Ludvig Lundgren 2022-07-07 16:28:14 +02:00 committed by GitHub
parent 31fbe013ff
commit 402596523d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 315 additions and 418 deletions

View file

@ -7,6 +7,7 @@ import (
"github.com/autobrr/autobrr/internal/domain"
"github.com/autobrr/autobrr/internal/download_client"
"github.com/autobrr/autobrr/internal/logger"
"github.com/autobrr/autobrr/pkg/qbittorrent"
"github.com/asaskevich/EventBus"
"github.com/dcarbone/zadapters/zstdlog"
@ -21,7 +22,11 @@ type Service interface {
ToggleEnabled(actionID int) error
RunAction(action *domain.Action, release domain.Release) ([]string, error)
CheckCanDownload(actions []domain.Action) bool
}
type qbitKey struct {
I int // type
N string // name
}
type service struct {
@ -30,14 +35,17 @@ type service struct {
repo domain.ActionRepo
clientSvc download_client.Service
bus EventBus.Bus
qbitClients map[qbitKey]*qbittorrent.Client
}
func NewService(log logger.Logger, repo domain.ActionRepo, clientSvc download_client.Service, bus EventBus.Bus) Service {
s := &service{
log: log.With().Str("module", "action").Logger(),
repo: repo,
clientSvc: clientSvc,
bus: bus,
log: log.With().Str("module", "action").Logger(),
repo: repo,
clientSvc: clientSvc,
bus: bus,
qbitClients: map[qbitKey]*qbittorrent.Client{},
}
s.subLogger = zstdlog.NewStdLoggerWithLevel(s.log.With().Logger(), zerolog.TraceLevel)