8000 Refactor logging by tadeboro · Pull Request #3000 · ansible/molecule · GitHub
[go: up one dir, main page]

Skip to content

Refactor logging - #3000

Merged
ssbarnea merged 4 commits into
ansible:masterfrom
xlab-steampunk:refactor-logging
Dec 3, 2020
Merged

ssbarnea merged 4 commits into
ansible:masterfrom
xlab-steampunk:refactor-logging

Conversation

@tadeboro
@tadeboro tadeboro commented Nov 28, 2020 •
Copy link
Copy Markdown
Contributor

Molecule reinvented the logging for some reason and did not use the standard Python logging facilities as they are meant to be used. This PR brings some sanity to the logging part of the code.

See commit messages for more detailed change descriptions.

PR Type

  • Bugfix Pull Request

Fixes: #2999

@ssbarnea
ssbarnea self-requested a review November 29, 2020 10:48
@ssbarnea ssbarnea left a comment
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.

I see a regression: "Found config file" which is printed before does no longer happen with this patch.

@tadeboro
tadeboro marked this pull request as ready for review November 29, 2020 21:29
@tadeboro
tadeboro requested a review from ssbarnea November 29, 2020 21:29
@ssbarnea ssbarnea left a comment
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you please fix the conflicts and ping me when this seams ready for review? (no known undesired side-effects). I will have to test it manually to assure we do not mess the logging even more with it but I need your confirmation first.

Tadej Borovšak added 4 commits December 3, 2020 13:24
When we removed custom logging handlers, we left behind a few helper
classes that we are not using anymore. This commit finishes the job of
removing custom bits from the codebase.
The main purpose of changes in current commit is to centralize the
logger configuration. Previously, molecule configured each and every
logger, creating new handler for each one, which made little sense.

In the new implementation, we only configure the root molecule logger.
All children logger instances inherit the configuration, making away
with duplication.

With our logging refactor, it also became feasible to use Python's
built-in logging facilities as instructed in the official docs.

Do note that we left the get_logger function in the logger module
because that piece of code is used by various molecule plugins (for
example, drivers) to obtain the properly configured logger instance.
But we again made sure we just nest the logger below the molecule root
logger and let it inherit the configuration.
Up until now, we ignored the verbosity setting and only used it to
control the verbosity of the Ansible subprocess. This commit reuses
the verbosity flag to also control the molecule verbosity.
@tadeboro
tadeboro commented Dec 3, 2020
Copy link
Copy Markdown
Contributor Author

I rebased the PR and tested it again locally. The only visible change of behavior from the master branch now should be the suppression of debug messages when running Molecule with no verbosity or debug flags.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Debug output on all molecule commands

2 participants

0