diff --git a/cmd/windows_exporter/main.go b/cmd/windows_exporter/main.go index 1edb3e09..9b61732e 100644 --- a/cmd/windows_exporter/main.go +++ b/cmd/windows_exporter/main.go @@ -125,7 +125,8 @@ func run(ctx context.Context, args []string) int { // Initialize collectors before loading and parsing CLI arguments collectors := collector.NewWithFlags(app) - if err := config.Parse(app, os.Args[1:]); err != nil { + //nolint:contextcheck + if err := config.Parse(app, args); err != nil { //nolint:sloglint // we do not have an logger yet slog.LogAttrs(ctx, slog.LevelError, "Failed to load configuration", slog.Any("err", err), @@ -135,11 +136,13 @@ func run(ctx context.Context, args []string) int { } debug.SetMemoryLimit(*memoryLimit) + logger, err := log.New(logConfig) if err != nil { logger.LogAttrs(ctx, slog.LevelError, "failed to create logger", slog.Any("err", err), ) + return 1 }