From 2a2eb6c4d7a1ab79a22e13950b02c6895244a255 Mon Sep 17 00:00:00 2001 From: Benjamin Kane <6081085+bbkane@users.noreply.github.com> Date: Fri, 8 Dec 2023 08:04:34 -0600 Subject: [PATCH 1/2] Add goimports --- .golangci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index ecbd686..b8536bf 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -15,10 +15,7 @@ linters: - gochecknoglobals - gochecknoinits - gofmt + - goimports - nonamedreturns - predeclared fast: false -linters-settings: - errcheck: - exclude-functions: - - (*go.bbkane.com/logos.Logger).Sync From 7b3f2c269a2ee86a5c786c0a4da152de2f2291b2 Mon Sep 17 00:00:00 2001 From: Benjamin Kane <6081085+bbkane@users.noreply.github.com> Date: Mon, 11 Dec 2023 04:38:38 -0600 Subject: [PATCH 2/2] don't ignore logger.Sync --- config.go | 6 +++++- grab.go | 7 ++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/config.go b/config.go index d80949b..f3ad461 100644 --- a/config.go +++ b/config.go @@ -35,7 +35,6 @@ func editConfig(ctx command.Context) error { zapLogger := logos.NewBBKaneZapLogger(lumberJackLogger, zap.DebugLevel, version) logger := logos.New(zapLogger, color) - defer logger.Sync() logger.LogOnPanic() configPath, configPathExists := ctx.Flags["--config"].(string) @@ -59,5 +58,10 @@ func editConfig(ctx command.Context) error { ) return err } + + err = logger.Sync() + if err != nil { + return fmt.Errorf("could not sync logger: %w", err) + } return nil } diff --git a/grab.go b/grab.go index d246e18..85863e2 100644 --- a/grab.go +++ b/grab.go @@ -370,7 +370,6 @@ func grab(ctx command.Context) error { zapLogger := logos.NewBBKaneZapLogger(lumberJackLogger, zap.DebugLevel, version) logger := logos.New(zapLogger, color) - defer logger.Sync() logger.LogOnPanic() subredditDestinations := ctx.Flags["--subreddit-destination"].([]string) @@ -430,5 +429,11 @@ func grab(ctx command.Context) error { grabSubreddit(timeoutCtx, logger, sr, posts) } + + err = logger.Sync() + if err != nil { + return fmt.Errorf("could not sync logger: %w", err) + } + return nil }