Skip to content

feat: add --log-level to control CLI logging - #52

Merged
karust merged 2 commits into
karust:mainfrom
Spidy092:codex/log-level-option
Sep 28, 2026
Merged

karust merged 2 commits into
karust:mainfrom
Spidy092:codex/log-level-option

Conversation

@Spidy092

@Spidy092 Spidy092 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Add --log-level so commands such as openserp search bing "golang" --log-level error can suppress warnings, including the warning emitted when no default config file exists.

The setting also supports app.log_level and OPENSERP_APP_LOG_LEVEL, with CLI > environment > config precedence. A non-empty value overrides the logging threshold selected by quiet/verbose/debug; an empty value retains existing defaults. Existing logger output destinations and browser settings are preserved.

Closes #44.

Why

The missing-config warning was logged before normal logger initialization. The merged log level is now applied before startup warnings and reapplied after logger setup. Invalid levels return a configuration error before search starts.

Testing

  • make fmt
  • make test (full suite with race detector)
  • make lint (go vet and golangci-lint v1.64.8)
  • go build
  • npx --yes @redocly/cli lint docs/openapi.yaml (passes with 9 warnings in the unchanged specification)
  • Regression tests for config/environment/CLI precedence, startup warnings, invalid values, explicit missing config paths, and legacy logging flag interactions.
  • Built CLI checks for help, warning suppression, environment overrides, and errors remaining visible on stderr. Used the unsupported Bing raw-mode path to avoid browser/network requests.

Live engine integration tests were not run; the change is confined to CLI logging configuration.

Checklist

  • Linked the related issue.
  • Updated README and example configuration.
  • Kept tests deterministic and independent of browsers/search engines.
  • Kept the change focused on logging configuration.

Spidy092 and others added 2 commits September 3, 2026 13:17
- Match the existing --log_format flag naming
- Apply the level after logger init: --log_level beats -q/-v/-d
- Trim README note and tests
@karust

karust commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Thanks for the PR!
I pushed a follow-up commit on top, to keep in line with the rest of the CLI:

  • Renamed the flag to --log_level to match --log_format and the other multi-word flags
  • A missing ./config.yaml no longer logs a warning at all. That was the actual noise in Add a --log-level option to control log verbosity聽#44 . A broken config still warns.
  • The level is applied once, after the logger is set up. --log_level beats -q/-v/-d, but a level from env/config gives way to -v/-d typed on the command line, so -v still works for debugging.

@karust
karust merged commit 112593b into karust:main Sep 28, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a --log-level option to control log verbosity

2 participants