Skip to content

Honor quiet flag for early startup log messages#1452

Open
citizen204 wants to merge 2 commits into
PyCQA:mainfrom
citizen204:fix-1250-quiet-early-logging
Open

Honor quiet flag for early startup log messages#1452
citizen204 wants to merge 2 commits into
PyCQA:mainfrom
citizen204:fix-1250-quiet-early-logging

Conversation

@citizen204

Copy link
Copy Markdown

Summary

With -q/--quiet/--silent, bandit still printed INFO messages emitted during option merging (e.g. [main] INFO Using ini file for skipped tests, [main] INFO Found project level .bandit file). The logger was initialized at INFO level at the top of main() and only lowered to WARN after argument/ini merging, so anything logged in between (notably _log_option_source() and _get_options_from_ini()) ignored the quiet flag.

This applies the same early sys.argv detection already used for -d/--debug to the quiet flags, so the logger starts at WARN when quiet is requested. Debug still takes precedence over quiet at startup, and the existing re-initialization logic later in main() is unchanged.

Verified: bandit --ini .bandit --silent target.py now emits no INFO lines, while output without --silent is unchanged.

Fixes #1250

Changes

  • bandit/cli/main.py: detect quiet flags in sys.argv during early logger initialization

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.

bug(standard_streams): console messages with the prefix “[main] INFO” if the configuration file in the INI format

1 participant