Skip to content

Commit f434788

Browse files
jkowalskiJulio López
andauthored
logging: simplified log levels (kopia#954)
Removed Warning, Notify and Fatal: * `Warning` => `Error` or `Info` * `Notify` => `Info` * `Fatal` was never used. Note that --log-level=warning is still supported for backwards compatibility, but it is the same as --log-level=error. Co-authored-by: Julio López <[email protected]>
1 parent 4638a6a commit f434788

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+112
-171
lines changed

cli/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func maybeRepositoryAction(act func(ctx context.Context, rep repo.Repository) er
199199

200200
if rep != nil && !mode.disableMaintenance {
201201
if merr := maybeRunMaintenance(ctx, rep); merr != nil {
202-
log(ctx).Warningf("error running maintenance: %v", merr)
202+
log(ctx).Errorf("error running maintenance: %v", merr)
203203
}
204204
}
205205

cli/auto_upgrade.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func maybeAutoUpgradeRepository(ctx context.Context, r repo.Repository) error {
2525
return nil
2626
}
2727

28-
log(ctx).Noticef("Setting default maintenance parameters...")
28+
log(ctx).Debugf("Setting default maintenance parameters...")
2929

3030
return repo.DirectWriteSession(ctx, dr, repo.WriteSessionOptions{
3131
Purpose: "setDefaultMaintenanceParameters",
@@ -42,8 +42,8 @@ func setDefaultMaintenanceParameters(ctx context.Context, rep repo.RepositoryWri
4242
return errors.Wrap(err, "unable to set maintenance params")
4343
}
4444

45-
log(ctx).Noticef(`
46-
Kopia will perform quick maintenance of the repository automatically every %v
45+
log(ctx).Infof(`
46+
NOTE: Kopia will perform quick maintenance of the repository automatically every %v
4747
and full maintenance every %v when running as %v.
4848
4949
See https://kopia.io/docs/advanced/maintenance/ for more information.

cli/command_index_recover.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func runRecoverBlockIndexesAction(ctx context.Context, rep repo.DirectRepository
5656
func recoverIndexFromSinglePackFile(ctx context.Context, rep repo.DirectRepositoryWriter, blobID blob.ID, length int64, totalCount *int) {
5757
recovered, err := rep.ContentManager().RecoverIndexFromPackBlob(ctx, blobID, length, *blockIndexRecoverCommit)
5858
if err != nil {
59-
log(ctx).Warningf("unable to recover index from %v: %v", blobID, err)
59+
log(ctx).Errorf("unable to recover index from %v: %v", blobID, err)
6060
return
6161
}
6262

cli/command_mount.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func runMountCommand(ctx context.Context, rep repo.Repository) error {
6767

6868
if *mountPointBrowse {
6969
if err := open.Start(ctrl.MountPath()); err != nil {
70-
log(ctx).Warningf("unable to browse %v", err)
70+
log(ctx).Errorf("unable to browse %v", err)
7171
}
7272
}
7373

cli/command_repository_sync.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func runSyncWithStorage(ctx context.Context, src blob.Reader, dst blob.Storage)
3939
log(ctx).Infof(" Destination: %v", dst.DisplayName())
4040

4141
if !*repositorySyncDelete {
42-
log(ctx).Noticef("NOTE: By default no BLOBs are deleted, pass --delete to allow it.")
42+
log(ctx).Infof("NOTE: By default no BLOBs are deleted, pass --delete to allow it.")
4343
}
4444

4545
if err := ensureRepositoriesHaveSameFormatBlob(ctx, src, dst); err != nil {
@@ -270,7 +270,7 @@ func syncCopyBlob(ctx context.Context, m blob.Metadata, src blob.Reader, dst blo
270270
if err := dst.SetTime(ctx, m.BlobID, m.Timestamp); err != nil {
271271
if errors.Is(err, blob.ErrSetTimeUnsupported) {
272272
setTimeUnsupportedOnce.Do(func() {
273-
log(ctx).Warningf("destination repository does not support setting time")
273+
log(ctx).Infof("destination repository does not support setting time")
274274
})
275275
}
276276

cli/command_server_start.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func runServer(ctx context.Context, rep repo.Repository) error {
100100
log(ctx).Infof("Shutting down...")
101101

102102
if err = httpServer.Shutdown(ctx); err != nil {
103-
log(ctx).Warningf("unable to shut down: %v", err)
103+
log(ctx).Debugf("unable to shut down: %v", err)
104104
}
105105
})
106106

@@ -131,7 +131,7 @@ func runServer(ctx context.Context, rep repo.Repository) error {
131131

132132
onExternalConfigReloadRequest(func() {
133133
if rerr := srv.Refresh(ctx); rerr != nil {
134-
log(ctx).Warningf("refresh failed: %v", rerr)
134+
log(ctx).Errorf("refresh failed: %v", rerr)
135135
}
136136
})
137137

@@ -264,7 +264,7 @@ func getAuthenticator(ctx context.Context) (auth.Authenticator, error) {
264264
authenticators = append(authenticators, auth.AuthenticateSingleUser(*serverUsername, randomPassword))
265265
}
266266

267-
log(ctx).Noticef(`
267+
log(ctx).Infof(`
268268
Server will allow connections from users whose accounts are stored in the repository.
269269
User accounts can be added using 'kopia server user add'.
270270
`)

cli/command_snapshot_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ func reportSnapshotStatus(ctx context.Context, manifest *snapshot.Manifest) erro
271271

272272
if ds := manifest.RootEntry.DirSummary; ds != nil {
273273
if ds.IgnoredErrorCount > 0 {
274-
log(ctx).Warningf("Ignored %v error(s) while snapshotting %v.", ds.IgnoredErrorCount, sourceInfo)
274+
log(ctx).Errorf("Ignored %v error(s) while snapshotting %v.", ds.IgnoredErrorCount, sourceInfo)
275275
}
276276

277277
if ds.FatalErrorCount > 0 {

cli/command_snapshot_estimate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ func (ep *estimateProgress) Processing(ctx context.Context, dirname string) {
3939

4040
func (ep *estimateProgress) Error(ctx context.Context, filename string, err error, isIgnored bool) {
4141
if isIgnored {
42-
log(ctx).Warningf("Ignored error in %v: %v", filename, err)
42+
log(ctx).Errorf("Ignored error in %v: %v", filename, err)
4343
} else {
4444
log(ctx).Errorf("Error in %v: %v", filename, err)
4545
}

cli/command_snapshot_list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func outputManifestGroups(ctx context.Context, rep repo.Repository, manifests []
146146

147147
pol, _, err := policy.GetEffectivePolicy(ctx, rep, src)
148148
if err != nil {
149-
log(ctx).Warningf("unable to determine effective policy for %v", src)
149+
log(ctx).Errorf("unable to determine effective policy for %v", src)
150150
} else {
151151
pol.RetentionPolicy.ComputeRetentionReasons(snapshotGroup)
152152
}
@@ -201,7 +201,7 @@ func outputManifestFromSingleSource(ctx context.Context, rep repo.Repository, ma
201201
}
202202

203203
if _, ok := ent.(object.HasObjectID); !ok {
204-
log(ctx).Warningf("entry does not have object ID: %v", ent, err)
204+
log(ctx).Errorf("entry does not have object ID: %v", ent, err)
205205
continue
206206
}
207207

cli/command_snapshot_migrate.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func runMigrateCommand(ctx context.Context, destRepo repo.RepositoryWriter) erro
5454
if !canceled {
5555
canceled = true
5656
for s, u := range activeUploaders {
57-
log(ctx).Warningf("canceling active uploader for %v", s)
57+
log(ctx).Infof("canceling active uploader for %v", s)
5858
u.Cancel()
5959
}
6060
}
@@ -99,7 +99,7 @@ func runMigrateCommand(ctx context.Context, destRepo repo.RepositoryWriter) erro
9999
}()
100100

101101
if err := migrateSingleSource(ctx, uploader, sourceRepo, destRepo, s); err != nil {
102-
log(ctx).Warningf("unable to migrate source: %v", err)
102+
log(ctx).Errorf("unable to migrate source: %v", err)
103103
}
104104
}(s)
105105
}
@@ -148,7 +148,7 @@ func migrateAllPolicies(ctx context.Context, sourceRepo repo.Repository, destRep
148148

149149
for _, pol := range policies {
150150
if err := migrateSinglePolicy(ctx, sourceRepo, destRepo, pol.Target()); err != nil {
151-
log(ctx).Warningf("unable to migrate policy for %v: %v", pol.Target(), err)
151+
log(ctx).Errorf("unable to migrate policy for %v: %v", pol.Target(), err)
152152
}
153153
}
154154

0 commit comments

Comments
 (0)