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

Add infrahub.tasks as built-in logger to InfrahubGenerator class #274

Merged
merged 3 commits into from
Feb 20, 2025

Conversation

FragmentedPacket
Copy link
Contributor

There have been a few requests to implement logging within generators within the CI pipeline output.

This adds an option to pass in your own logger or default to infrahub.tasks.

I also added init_logging in the generator CTL command so we can take advantage of the logging on the console as well.

Please let me know if there is a more optimal way, but this might be a good thing to include in a few of the classes that run within the CI pipeline.

Copy link

codecov bot commented Feb 15, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
infrahub_sdk/ctl/generator.py 50.00% 1 Missing ⚠️
infrahub_sdk/generator.py 50.00% 1 Missing ⚠️
@@            Coverage Diff             @@
##           stable     #274      +/-   ##
==========================================
- Coverage   70.36%   70.34%   -0.03%     
==========================================
  Files          82       81       -1     
  Lines        7497     7502       +5     
  Branches     1389     1391       +2     
==========================================
+ Hits         5275     5277       +2     
- Misses       1848     1851       +3     
  Partials      374      374              
Flag Coverage Δ
integration-tests 22.44% <0.00%> (-0.02%) ⬇️
python-3.10 45.50% <25.00%> (-0.06%) ⬇️
python-3.11 45.50% <25.00%> (-0.06%) ⬇️
python-3.12 45.50% <25.00%> (-0.06%) ⬇️
python-3.13 45.50% <25.00%> (-0.06%) ⬇️
python-3.9 45.50% <25.00%> (-0.06%) ⬇️
python-filler-3.12 24.00% <25.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
infrahub_sdk/ctl/generator.py 23.21% <50.00%> (-0.43%) ⬇️
infrahub_sdk/generator.py 35.89% <50.00%> (+0.37%) ⬆️

... and 8 files with indirect coverage changes

Copy link
Contributor

@dgarros dgarros left a comment

Choose a reason for hiding this comment

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

LGTM, please can you add a news fragment to include something in the release note

@FragmentedPacket FragmentedPacket merged commit 75aebe4 into stable Feb 20, 2025
15 checks passed
@FragmentedPacket FragmentedPacket deleted the may-202502-generator-logging branch February 20, 2025 14:21
dgarros pushed a commit that referenced this pull request Feb 23, 2025
…274)

* Test building in logger to InfrahubGenerator class to allow logs to be easily propagated via CTL and CI pipeline logs.

* Remove unused logging import.

* Add changelog to describe change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants