add logging
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
5089535fce
commit
e1aff8d16b
7 changed files with 73 additions and 33 deletions
|
|
@ -5,7 +5,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"log/slog"
|
||||
"path/filepath"
|
||||
|
||||
aptclone "github.com/syonad/clonepack/internal/clone/apt"
|
||||
|
|
@ -59,7 +59,7 @@ func (s *CloneService) runClone(repoID, jobID int64, repo *store.Repo) {
|
|||
ctx := context.Background()
|
||||
|
||||
if err := s.jobStore.MarkCloneJobStarted(ctx, jobID); err != nil {
|
||||
log.Printf("clone job %d: failed to mark started: %v", jobID, err)
|
||||
slog.Error("clone job: failed to mark started", "job_id", jobID, "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -70,12 +70,12 @@ func (s *CloneService) runClone(repoID, jobID int64, repo *store.Repo) {
|
|||
case "rpm":
|
||||
cloner := rpm.New(repo.SourceURL, destDir)
|
||||
cloner.OnProgress = func(p rpm.Progress) {
|
||||
log.Printf("clone job %d: %s (%d bytes)", jobID, p.File, p.BytesDone)
|
||||
slog.Debug("clone progress", "job_id", jobID, "file", p.File, "bytes", p.BytesDone)
|
||||
}
|
||||
if err := cloner.Clone(ctx); err != nil {
|
||||
cloneErr = err
|
||||
} else if err := rpm.RegenerateMetadata(destDir); err != nil {
|
||||
log.Printf("clone job %d: metadata regeneration failed: %v", jobID, err)
|
||||
slog.Warn("clone job: metadata regeneration failed", "job_id", jobID, "error", err)
|
||||
}
|
||||
|
||||
case "apt":
|
||||
|
|
@ -86,7 +86,7 @@ func (s *CloneService) runClone(repoID, jobID int64, repo *store.Repo) {
|
|||
}
|
||||
cloner := aptclone.New(repo.SourceURL, destDir, cfg)
|
||||
cloner.OnProgress = func(file string, bytes int64) {
|
||||
log.Printf("clone job %d: %s (%d bytes)", jobID, file, bytes)
|
||||
slog.Debug("clone progress", "job_id", jobID, "file", file, "bytes", bytes)
|
||||
}
|
||||
cloneErr = cloner.Clone(ctx)
|
||||
}
|
||||
|
|
@ -94,10 +94,10 @@ func (s *CloneService) runClone(repoID, jobID int64, repo *store.Repo) {
|
|||
if cloneErr != nil {
|
||||
errMsg := cloneErr.Error()
|
||||
_ = s.jobStore.MarkCloneJobFinished(ctx, jobID, store.CloneJobFailed, &errMsg)
|
||||
log.Printf("clone job %d: failed: %v", jobID, cloneErr)
|
||||
slog.Error("clone job failed", "job_id", jobID, "error", cloneErr)
|
||||
return
|
||||
}
|
||||
|
||||
_ = s.jobStore.MarkCloneJobFinished(ctx, jobID, store.CloneJobCompleted, nil)
|
||||
log.Printf("clone job %d: completed", jobID)
|
||||
slog.Info("clone job completed", "job_id", jobID)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue