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 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 }