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 debug logging to parsing, evaluation and validation #202

Merged
merged 1 commit into from
Jul 6, 2022

Conversation

hf-kklein
Copy link
Contributor

The purpose is not to log each and everything but help users of ahbicht to understand the behaviour of ahbicht within their application (with their own evaluators, resolvers etc)

The purpose is not to log each and everything but help users of ahbicht to understand the behaviour of ahbicht within their application (with their own evaluators, resolvers etc)
@hf-kklein hf-kklein requested review from a team, hf-aschloegl and hf-krechan July 6, 2022 06:04
Copy link
Collaborator

@hf-krechan hf-krechan left a comment

Choose a reason for hiding this comment

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

I would prefer f-strings if they are possible in the log

@@ -53,6 +56,9 @@ def __init__(self):
match = Evaluator._evaluation_method_name_pattern.match(candidate[0])
if match:
self._evaluation_methods[match.groupdict()["condition_key"]] = candidate[1]
self.logger.info(
"Instantiated %s and found %i evaluation methods", self.__class__.__name__, len(self._evaluation_methods)
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it not possible to use f-strings in logging?

Copy link
Contributor Author

@hf-kklein hf-kklein Jul 6, 2022

Choose a reason for hiding this comment

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

It's rejected by pylint:
https://pylint.pycqa.org/en/latest/user_guide/messages/warning/logging-fstring-interpolation.html
background: creating the final log message from the template is deferred as long as possible:
https://docs.python.org/3/howto/logging.html#optimization

More (easily understandable) background:

This is not python-specific btw. Prefering log-templates over string interpolation in log messages is also recommended for .NET (and e.g. suggested by rider/resharper).

@hf-kklein hf-kklein merged commit b13ec0c into main Jul 6, 2022
@hf-kklein hf-kklein deleted the logging branch July 6, 2022 08:01
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