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 logging filename, level and format #12

Merged
merged 8 commits into from
Aug 16, 2023
Merged

Add logging filename, level and format #12

merged 8 commits into from
Aug 16, 2023

Conversation

jesusbv
Copy link
Contributor

@jesusbv jesusbv commented Aug 4, 2023

Should be merged after #10

@jesusbv jesusbv self-assigned this Aug 4, 2023
@jesusbv jesusbv force-pushed the add-logging-file branch 2 times, most recently from ca4f4cc to 1a8a467 Compare August 4, 2023 09:38
@jesusbv jesusbv marked this pull request as draft August 4, 2023 09:57
@jesusbv jesusbv force-pushed the add-logging-file branch 2 times, most recently from 786caa8 to afcc177 Compare August 4, 2023 12:13
@jesusbv jesusbv marked this pull request as ready for review August 4, 2023 12:14
csp_billing_adapter_local/plugin.py Outdated Show resolved Hide resolved
csp_billing_adapter_local/plugin.py Outdated Show resolved Hide resolved
tests/unit/test_plugin.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@smarlowucf smarlowucf left a comment

Choose a reason for hiding this comment

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

No matter where the adapter is deployed we want logging. If there are config options for the logger I think those would be handled in core code where the logger is instantiated.

If there's an additional handler needed by a plugin beyond stream handler I think that's best setup in the plugin setup hook. For VM based adapters it means there's a stream handler and a file based handler. Which seems fine.

Set the logging on setup_adapter and tests
tests/data/config.yaml Outdated Show resolved Hide resolved
csp_billing_adapter_local/plugin.py Outdated Show resolved Hide resolved
csp_billing_adapter_local/plugin.py Outdated Show resolved Hide resolved
tests/data/config.yaml Show resolved Hide resolved
@jesusbv jesusbv requested a review from rjschwei August 16, 2023 09:24
@csp_billing_adapter.hookimpl
def setup_adapter(config: Config):
log_to_file = logging.FileHandler(CSP_LOG_FILEPATH)
csp_log = logging.getLogger(LOGGER_NAME)
Copy link
Contributor

Choose a reason for hiding this comment

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

should either be csp_log = log or log = logging.getLogger(LOGGER_NAME) on line 37 should be removed. Why create the module variable at the top level when it is not being used?

Remove get logger call in favor of
using log previously declared
@jesusbv jesusbv merged commit afb62c7 into main Aug 16, 2023
6 checks passed
@jesusbv jesusbv deleted the add-logging-file branch August 24, 2023 15:10
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.

4 participants