8000 Enable multiple section wrappers by ssbarnea · Pull Request #2984 · ansible/molecule · GitHub
[go: up one dir, main page]

Skip to content

Enable multiple section wrappers - #2984

Merged
ssbarnea merged 1 commit into
masterfrom
devel
Nov 19, 2020
Merged

ssbarnea merged 1 commit into
masterfrom
devel

Conversation

@ssbarnea
Copy link
Copy Markdown
Member

Moves the recently added section_logger to the logger module and enable us to use multiple wrappers. This should make
implementation of #2976 much easier.

@ssbarnea
Copy link
Copy Markdown
Member Author

@cognifloyd Should this be enough to make the section adding easy and clean?

@cognifloyd cognifloyd left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where do you want the CI-specific formatting to live? Under console.py? Under logger.py? In a utility file somewhere else?

Do you like the class-style format better? Or are you cool with the function wrapper?

Happy to adjust the PR, I'm just not sure what your vision is for a more generic impl that allows for adding terminal-specific escapes later.

Are you thinking that the CI-specific wrappers should live in enrich somewhere?

Comment thread src/molecule/logger.py

def get_section_loggers() -> Iterable[Callable]:
"""Return a list of section wrappers to be added."""
return [section_logger]
@cognifloyd cognifloyd Nov 19, 2020 •
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

are you imagining a separate wrapper function for each of the output types?

return [github_actions_grouper, gitlab_sectioner, travis_ci_folder, section_logger]

Then the environment var checks would happen during each of those?
or something more like what I had before:

return [ci_section_wrapper, section_logger]

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Add them to the logger module. I was considering console initially but due to some circular import issues I decided to go for logger. logger can import console but console does not, this being the main reason.

Yep, I did fancy adding these to enrich but I am afraid that it may not be so easy. If I am correct, there wrappers may require some parameters like section name.

For the moment just extend get_section_loggers to make it return additional wrappens when needed, add them inside the same file and also add lru_cache() wrapper on it for performance reasons, as we do not want it to run each time it wraps a class.

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.

2 participants

0