Skip to content

Delay the creation of the LogfileHandler#4677

Draft
LecrisUT wants to merge 16 commits intoteemtee:mainfrom
LecrisUT:feat/delay-logger
Draft

Delay the creation of the LogfileHandler#4677
LecrisUT wants to merge 16 commits intoteemtee:mainfrom
LecrisUT:feat/delay-logger

Conversation

@LecrisUT
Copy link
Contributor

Preparation for some refactoring of the workdir initialization logic, see the comment

tmt/tmt/utils/__init__.py

Lines 2463 to 2470 in eb8ed04

# TODO: chicken and egg problem: when `Common` is instantiated, the workdir
# path might be already known, but it's often not created yet. Therefore
# a logfile handler cannot be attached to the given logger.
# This is a problem, as we modify a given logger, and we may modify the
# incorrect logger, and we may modify 3rd party app logger. The solution
# to our little logging problem would probably be related to refactoring
# of workdir creation some day in the future.
self._logger.add_logfile_handler(workdir / tmt.log.LOG_FILENAME)

The purpose of this is to be able to:

  • move the logic of defining the Common._workdir is defined and make it available much earlier. Refactoring where/when to do the creation of the workdir would follow afterwards
  • move where the add_logfile_handler is executed and do not add it unless we are in a tmt run loop

Pull Request Checklist

  • implement the feature

Depends-on: #4642

LecrisUT added 16 commits March 10, 2026 12:38
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
Signed-off-by: Cristian Le <git@lecris.dev>
@LecrisUT LecrisUT added status | blocked The merging of PR is blocked on some other issue code | logging Changes related to debug logging status | blocking other work An important pull request, blocking other pull requests or issues ci | full test Pull request is ready for the full test execution labels Mar 11, 2026
Copy link
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 introduces a warnings.yaml log and refactors workdir loading. A change to LogfileHandler breaks stacktrace logging to files. The default for the new with_stacktrace parameter should be True to fix this for existing code. The handler for warnings.yaml must then explicitly set this to False.

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 code | logging Changes related to debug logging status | blocked The merging of PR is blocked on some other issue status | blocking other work An important pull request, blocking other pull requests or issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant