From bf0153267d09d11062e83ec9ee6ef8b8bda06ead Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Sat, 2 Oct 2021 15:34:41 +0200 Subject: [PATCH] Logs: More consistent log format for commands --- internal/commands/backup.go | 2 +- internal/commands/cleanup.go | 2 +- internal/commands/convert.go | 2 +- internal/commands/copy.go | 4 +++- internal/commands/faces.go | 14 +++++++------- internal/commands/import.go | 4 +++- internal/commands/index.go | 2 +- internal/commands/migrate.go | 2 +- internal/commands/moments.go | 2 +- internal/commands/optimize.go | 2 +- internal/commands/purge.go | 4 +--- internal/commands/resample.go | 4 +--- internal/commands/reset.go | 2 +- internal/commands/restore.go | 2 +- 14 files changed, 24 insertions(+), 24 deletions(-) diff --git a/internal/commands/backup.go b/internal/commands/backup.go index 656f40a98..1c24095ea 100644 --- a/internal/commands/backup.go +++ b/internal/commands/backup.go @@ -186,7 +186,7 @@ func backupAction(ctx *cli.Context) error { elapsed := time.Since(start) - log.Infof("backup completed [%s]", elapsed) + log.Infof("backup completed in %s", elapsed) conf.Shutdown() diff --git a/internal/commands/cleanup.go b/internal/commands/cleanup.go index b61ae90e7..33117a35f 100644 --- a/internal/commands/cleanup.go +++ b/internal/commands/cleanup.go @@ -57,7 +57,7 @@ func cleanUpAction(ctx *cli.Context) error { if thumbs, orphans, err := w.Start(opt); err != nil { return err } else { - log.Infof("cleanup: removed %s and %s [%s]", english.Plural(orphans, "index entry", "index entries"), english.Plural(thumbs, "thumbnail", "thumbnails"), time.Since(start)) + log.Infof("removed %s and %s in %s", english.Plural(orphans, "index entry", "index entries"), english.Plural(thumbs, "thumbnail", "thumbnails"), time.Since(start)) } conf.Shutdown() diff --git a/internal/commands/convert.go b/internal/commands/convert.go index 38a5683fc..2a9746502 100644 --- a/internal/commands/convert.go +++ b/internal/commands/convert.go @@ -58,7 +58,7 @@ func convertAction(ctx *cli.Context) error { elapsed := time.Since(start) - log.Infof("converting completed [%s]", elapsed) + log.Infof("converting completed in %s", elapsed) return nil } diff --git a/internal/commands/copy.go b/internal/commands/copy.go index 0c8e7cad4..1c4d87efa 100644 --- a/internal/commands/copy.go +++ b/internal/commands/copy.go @@ -71,7 +71,9 @@ func copyAction(ctx *cli.Context) error { elapsed := time.Since(start) - log.Infof("import completed [%s]", elapsed) + log.Infof("import completed in %s", elapsed) + conf.Shutdown() + return nil } diff --git a/internal/commands/faces.go b/internal/commands/faces.go index de016ff98..1c2e26a05 100644 --- a/internal/commands/faces.go +++ b/internal/commands/faces.go @@ -99,7 +99,7 @@ func facesStatsAction(ctx *cli.Context) error { } else { elapsed := time.Since(start) - log.Infof("completed [%s]", elapsed) + log.Infof("completed in %s", elapsed) } conf.Shutdown() @@ -130,7 +130,7 @@ func facesAuditAction(ctx *cli.Context) error { } else { elapsed := time.Since(start) - log.Infof("completed [%s]", elapsed) + log.Infof("completed in %s", elapsed) } conf.Shutdown() @@ -174,7 +174,7 @@ func facesResetAction(ctx *cli.Context) error { } else { elapsed := time.Since(start) - log.Infof("completed [%s]", elapsed) + log.Infof("completed in %s", elapsed) } conf.Shutdown() @@ -212,7 +212,7 @@ func facesResetAllAction(ctx *cli.Context) error { } else { elapsed := time.Since(start) - log.Infof("completed [%s]", elapsed) + log.Infof("completed in %s", elapsed) } conf.Shutdown() @@ -278,7 +278,7 @@ func facesIndexAction(ctx *cli.Context) error { elapsed := time.Since(start) - log.Infof("indexed %d files [%s]", len(indexed), elapsed) + log.Infof("indexed %s in %s", english.Plural(len(indexed), "file", "files"), elapsed) conf.Shutdown() @@ -312,7 +312,7 @@ func facesUpdateAction(ctx *cli.Context) error { } else { elapsed := time.Since(start) - log.Infof("completed [%s]", elapsed) + log.Infof("completed in %s", elapsed) } conf.Shutdown() @@ -343,7 +343,7 @@ func facesOptimizeAction(ctx *cli.Context) error { } else { elapsed := time.Since(start) - log.Infof("%d face clusters merged [%s]", res.Merged, elapsed) + log.Infof("%s merged in %s", english.Plural(res.Merged, "face cluster", "face clusters"), elapsed) } conf.Shutdown() diff --git a/internal/commands/import.go b/internal/commands/import.go index 1d9920213..55924ce7a 100644 --- a/internal/commands/import.go +++ b/internal/commands/import.go @@ -71,7 +71,9 @@ func importAction(ctx *cli.Context) error { elapsed := time.Since(start) - log.Infof("import completed [%s]", elapsed) + log.Infof("import completed in %s", elapsed) + conf.Shutdown() + return nil } diff --git a/internal/commands/index.go b/internal/commands/index.go index f02347a36..fef0dcd23 100644 --- a/internal/commands/index.go +++ b/internal/commands/index.go @@ -110,7 +110,7 @@ func indexAction(ctx *cli.Context) error { elapsed := time.Since(start) - log.Infof("indexed %d files [%s]", len(indexed), elapsed) + log.Infof("indexed %s in %s", english.Plural(len(indexed), "file", "files"), elapsed) conf.Shutdown() diff --git a/internal/commands/migrate.go b/internal/commands/migrate.go index 03617a0ad..0a60a74af 100644 --- a/internal/commands/migrate.go +++ b/internal/commands/migrate.go @@ -35,7 +35,7 @@ func migrateAction(ctx *cli.Context) error { elapsed := time.Since(start) - log.Infof("database migration completed [%s]", elapsed) + log.Infof("database migration completed in %s", elapsed) conf.Shutdown() diff --git a/internal/commands/moments.go b/internal/commands/moments.go index ce1e5697f..e2c51eb99 100644 --- a/internal/commands/moments.go +++ b/internal/commands/moments.go @@ -44,7 +44,7 @@ func momentsAction(ctx *cli.Context) error { } else { elapsed := time.Since(start) - log.Infof("completed [%s]", elapsed) + log.Infof("completed in %s", elapsed) } conf.Shutdown() diff --git a/internal/commands/optimize.go b/internal/commands/optimize.go index 7e90101d9..f9133dc06 100644 --- a/internal/commands/optimize.go +++ b/internal/commands/optimize.go @@ -45,7 +45,7 @@ func optimizeAction(ctx *cli.Context) error { } else { elapsed := time.Since(start) - log.Infof("completed [%s]", elapsed) + log.Infof("completed in %s", elapsed) } conf.Shutdown() diff --git a/internal/commands/purge.go b/internal/commands/purge.go index aff4c7f80..32977916c 100644 --- a/internal/commands/purge.go +++ b/internal/commands/purge.go @@ -76,9 +76,7 @@ func purgeAction(ctx *cli.Context) error { if files, photos, err := w.Start(opt); err != nil { return err } else { - elapsed := time.Since(start) - - log.Infof("purge: removed %s and %s [%s]", english.Plural(len(files), "file", "files"), english.Plural(len(photos), "photo", "photos"), elapsed) + log.Infof("purged %s and %s in %s", english.Plural(len(files), "file", "files"), english.Plural(len(photos), "photo", "photos"), time.Since(start)) } conf.Shutdown() diff --git a/internal/commands/resample.go b/internal/commands/resample.go index 91c9b126f..c53df0f5a 100644 --- a/internal/commands/resample.go +++ b/internal/commands/resample.go @@ -44,9 +44,7 @@ func resampleAction(ctx *cli.Context) error { return err } - elapsed := time.Since(start) - - log.Infof("thumbnails created [%s]", elapsed) + log.Infof("thumbnails created in %s", time.Since(start)) return nil } diff --git a/internal/commands/reset.go b/internal/commands/reset.go index 8433a2aee..888a12845 100644 --- a/internal/commands/reset.go +++ b/internal/commands/reset.go @@ -57,7 +57,7 @@ func resetAction(ctx *cli.Context) error { entity.Admin.InitPassword(conf.AdminPassword()) } - log.Infof("database reset completed [%s]", time.Since(start)) + log.Infof("database reset completed in %s", time.Since(start)) } else { log.Infof("keeping index database") } diff --git a/internal/commands/restore.go b/internal/commands/restore.go index 1517d9e1a..1c4c3e1a3 100644 --- a/internal/commands/restore.go +++ b/internal/commands/restore.go @@ -212,7 +212,7 @@ func restoreAction(ctx *cli.Context) error { elapsed := time.Since(start) - log.Infof("backup restored [%s]", elapsed) + log.Infof("backup restored in %s", elapsed) conf.Shutdown()