Skip to content

Add option --log-cli-level in python-pytest-dispatch #74

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 10, 2024
Merged

Add option --log-cli-level in python-pytest-dispatch #74

merged 1 commit into from
Aug 10, 2024

Conversation

rodrigo-morales-1
Copy link
Contributor

@rodrigo-morales-1 rodrigo-morales-1 commented Aug 10, 2024

When writing tests, I usually display debugging information by using logging.info(...) or logging.debug(...). When --log-cli-level=debug is passed to pytest, logging.info and logging.debug messages are shown. When --log-cli-level=info is passed to pytest, logging.info messages are shown. In this pull request, I introduce changes to include --log-cli-level in python-pytest-dispatch so that users can conveniently toggle this option.

I wanted to use -l as the shortcut for setting --log-cli-level, but -l is already used in python-pytest-dispatch for setting --showlocals. For this reason, I ended up using --l.

It is worth mentioning that pytest not only defines --log-cli-level, but it also defines --log-level, --log-file-level. However, I don't know what --log-level and --log-file-level are used for. I have only used --log-cli-level because suits my use case

$ pytest --help
logging:
  --log-level=LEVEL     Level of messages to catch/display. Not set by default,
                        so it depends on the root/parent log handler's effective
                        level, where it is "WARNING" by default.
  --log-format=LOG_FORMAT
                        Log format used by the logging module
  --log-date-format=LOG_DATE_FORMAT
                        Log date format used by the logging module
  --log-cli-level=LOG_CLI_LEVEL
                        CLI logging level
  --log-cli-format=LOG_CLI_FORMAT
                        Log format used by the logging module
  --log-cli-date-format=LOG_CLI_DATE_FORMAT
                        Log date format used by the logging module
  --log-file=LOG_FILE   Path to a file when logging will be written to
  --log-file-mode={w,a}
                        Log file open mode
  --log-file-level=LOG_FILE_LEVEL
                        Log file logging level
  --log-file-format=LOG_FILE_FORMAT
                        Log format used by the logging module
  --log-file-date-format=LOG_FILE_DATE_FORMAT
                        Log date format used by the logging module
  --log-auto-indent=LOG_AUTO_INDENT
                        Auto-indent multiline messages passed to the logging
                        module. Accepts true|on, false|off or an integer.
  --log-disable=LOGGER_DISABLE
                        Disable a logger by name. Can be passed multiple times.

@wbolster wbolster merged commit bfcd288 into wbolster:main Aug 10, 2024
@wbolster
Copy link
Owner

lgtm, thanks 🚀

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.

2 participants