From 10bea108e36224e85d2682ce0dd9669ed7bf8350 Mon Sep 17 00:00:00 2001 From: simulot Date: Sun, 22 Dec 2024 20:13:48 +0100 Subject: [PATCH] New "Warning" Log Level Fixes #573 --- .../e2eTests/upload/e2e_from_folder_test.go | 2 +- internal/fileevent/fileevents.go | 27 ++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/internal/e2eTests/upload/e2e_from_folder_test.go b/internal/e2eTests/upload/e2e_from_folder_test.go index 656124c..9635429 100644 --- a/internal/e2eTests/upload/e2e_from_folder_test.go +++ b/internal/e2eTests/upload/e2e_from_folder_test.go @@ -35,7 +35,7 @@ func TestUploadFromGooglePhotos(t *testing.T) { "upload", "from-google-photos", "--server=" + myEnv["IMMICHGO_SERVER"], "--api-key=" + myEnv["IMMICHGO_APIKEY"], - "--no-ui", + // "--no-ui", myEnv["IMMICHGO_TESTFILES"] + "/demo takeout/Takeout", }) diff --git a/internal/fileevent/fileevents.go b/internal/fileevent/fileevents.go index 7bdd984..a3953af 100644 --- a/internal/fileevent/fileevents.go +++ b/internal/fileevent/fileevents.go @@ -91,6 +91,30 @@ var _code = map[Code]string{ Error: "error", } +var _logLevels = map[Code]slog.Level{ + DiscoveredImage: slog.LevelInfo, + DiscoveredVideo: slog.LevelInfo, + DiscoveredDiscarded: slog.LevelWarn, + DiscoveredUnsupported: slog.LevelWarn, + DiscoveredUseless: slog.LevelWarn, + AnalysisAssociatedMetadata: slog.LevelInfo, + AnalysisMissingAssociatedMetadata: slog.LevelWarn, + AnalysisLocalDuplicate: slog.LevelWarn, + UploadNotSelected: slog.LevelWarn, + UploadUpgraded: slog.LevelInfo, + UploadServerBetter: slog.LevelInfo, + UploadAlbumCreated: slog.LevelInfo, + UploadServerError: slog.LevelError, + Uploaded: slog.LevelInfo, + Stacked: slog.LevelInfo, + LivePhoto: slog.LevelInfo, + Metadata: slog.LevelInfo, + INFO: slog.LevelInfo, + Written: slog.LevelInfo, + Tagged: slog.LevelInfo, + Error: slog.LevelError, +} + func (e Code) String() string { if s, ok := _code[e]; ok { return s @@ -120,10 +144,11 @@ func (r *Recorder) Log() *slog.Logger { func (r *Recorder) Record(ctx context.Context, code Code, file slog.LogValuer, args ...any) { atomic.AddInt64(&r.counts[code], 1) if r.log != nil { - level := slog.LevelInfo + level := _logLevels[code] if file != nil { args = append([]any{"file", file.LogValue()}, args...) } + for _, a := range args { if a == "error" { level = slog.LevelError