Skip to content

Limit verbose/debug levels#4836

Draft
happz wants to merge 3 commits into
mainfrom
verbose-debug-levels-limited
Draft

Limit verbose/debug levels#4836
happz wants to merge 3 commits into
mainfrom
verbose-debug-levels-limited

Conversation

@happz
Copy link
Copy Markdown
Contributor

@happz happz commented Apr 28, 2026

Enforced in code by the use of Literal type alias, runtime check follow the normalize_* pattern. Updated documentation and help texts to reflect the change.

Related to #4814.

Pull Request Checklist

  • implement the feature
  • write the documentation
  • extend the test coverage
  • update the specification
  • adjust plugin docstring
  • modify the json schema
  • mention the version
  • include a release note

Enforced in code by the use of `Literal` type alias, runtime check
follow the `normalize_*` pattern. Updated documentation and help texts
to reflect the change.

Related to #4814.
@happz happz added the ci | full test Pull request is ready for the full test execution label Apr 28, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request standardizes verbosity and debug levels by introducing dedicated type aliases and normalization functions for input validation. Feedback includes catching GeneralError in tmt/trying.py to prevent crashes, removing redundant None checks, and aligning the VerbosityLevel range with the help text. Additionally, restore the logging level in tmt/utils/init.py to avoid increased output noise.

Comment thread tmt/trying.py Outdated
Comment thread tmt/trying.py Outdated
Comment thread tmt/log.py
Comment thread tmt/utils/__init__.py
@github-project-automation github-project-automation Bot moved this to backlog in planning Apr 29, 2026
Comment thread tmt/options.py
Comment on lines +209 to +213
help="""
Emit debugging information. Can be used up to four times
(``-d`` to ``-dddd``, or ``TMT_DEBUG=1`` to ``TMT_DEBUG=4``)
for increasingly detailed logging.
""",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be a good place to put the breakdown of what to expect in each verbosity level

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends what lands first, whether this PR or docs describing the levels. I tried to capture the current state of things, I can include the descriptions, but they are not ready yet.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will revisit this comment once either of them get into a sprint

Comment thread tmt/log.py
Comment on lines +67 to +75
#: Supported verbosity levels.
VERBOSITY_LEVELS = (0, 1, 2, 3, 4)
#: Supported debug levels.
DEBUG_LEVELS = (0, 1, 2, 3, 4)

#: A type of verbosity level values accepted by logging functions.
VerbosityLevel: 'TypeAlias' = Literal[0, 1, 2, 3, 4]
#: A type of debug level values accepted by logging functions.
DebugLevel: 'TypeAlias' = Literal[0, 1, 2, 3, 4]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See tmt.steps.ACTIONS about de-duplicating these

Comment thread tmt/log.py
DebugLevel: 'TypeAlias' = Literal[0, 1, 2, 3, 4]

DEFAULT_VERBOSITY_LEVEL: VerbosityLevel = 0
DEFAULT_DEBUG_LEVEL: DebugLevel = 0
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't debug level 0 be dropped (maybe in subsequent patch)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's allowed, 0 means "no debugging messages". I think I could change the type and add another default to express what debug() accepts - Logger.debug_level can be set to 0, but debug(level=0) is indeed nonsense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci | full test Pull request is ready for the full test execution

Projects

Status: backlog

Development

Successfully merging this pull request may close these issues.

3 participants