Skip to content
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

Enable multiple section wrappers #2984

Merged
merged 1 commit into from
Nov 19, 2020
Merged

Enable multiple section wrappers #2984

merged 1 commit into from
Nov 19, 2020

Conversation

ssbarnea
Copy link
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
Member Author

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

Copy link
Contributor

@cognifloyd cognifloyd left a comment

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?


def get_section_loggers() -> Iterable[Callable]:
"""Return a list of section wrappers to be added."""
return [section_logger]
Copy link
Contributor

@cognifloyd cognifloyd Nov 19, 2020

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
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