mirror of
https://github.com/kopia/kopia.git
synced 2026-05-07 14:26:51 -04:00
cli: 'snapshot create' switched all stderr output to use logger (#663)
This allows 'kopia snap create --all --log-level=warning --no-progress' to produce no console output unless an error is encountered.
This commit is contained in:
@@ -252,6 +252,10 @@ func (p *cliProgress) Finish() {
|
||||
atomic.StoreInt32(&p.uploading, 0)
|
||||
|
||||
p.output(defaultColor, "")
|
||||
|
||||
if *enableProgress {
|
||||
printStderr("\n")
|
||||
}
|
||||
}
|
||||
|
||||
var progress = &cliProgress{}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -67,7 +66,7 @@ func runSnapshotCommand(ctx context.Context, rep repo.Repository) error {
|
||||
|
||||
for _, snapshotDir := range sources {
|
||||
if u.IsCanceled() {
|
||||
printStderr("Upload canceled\n")
|
||||
log(ctx).Infof("Upload canceled")
|
||||
break
|
||||
}
|
||||
|
||||
@@ -144,7 +143,7 @@ func startTimeAfterEndTime(startTime, endTime time.Time) bool {
|
||||
}
|
||||
|
||||
func snapshotSingleSource(ctx context.Context, rep repo.Repository, u *snapshotfs.Uploader, sourceInfo snapshot.SourceInfo) error {
|
||||
printStderr("Snapshotting %v ...\n", sourceInfo)
|
||||
log(ctx).Infof("Snapshotting %v ...", sourceInfo)
|
||||
|
||||
t0 := clock.Now()
|
||||
|
||||
@@ -215,11 +214,11 @@ func snapshotSingleSource(ctx context.Context, rep repo.Repository, u *snapshotf
|
||||
|
||||
if ds := manifest.RootEntry.DirSummary; ds != nil {
|
||||
if ds.NumFailed > 0 {
|
||||
errorColor.Fprintf(os.Stderr, "\nIgnored %v errors while snapshotting.", ds.NumFailed) //nolint:errcheck
|
||||
log(ctx).Warningf("Ignored %v errors while snapshotting %v.", ds.NumFailed, sourceInfo)
|
||||
}
|
||||
}
|
||||
|
||||
printStderr("\nCreated%v snapshot with root %v and ID %v in %v\n", maybePartial, manifest.RootObjectID(), snapID, clock.Since(t0).Truncate(time.Second))
|
||||
log(ctx).Infof("Created%v snapshot with root %v and ID %v in %v", maybePartial, manifest.RootObjectID(), snapID, clock.Since(t0).Truncate(time.Second))
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user