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

Don't use f-strings during logging #360

Open
adswa opened this issue Mar 2, 2023 · 0 comments
Open

Don't use f-strings during logging #360

adswa opened this issue Mar 2, 2023 · 0 comments
Assignees

Comments

@adswa
Copy link
Member

adswa commented Mar 2, 2023

I'm recording a comment of @mih in the chat because it applies to metalad:

logging should not use f-strings

As also outlined in the Design document:

A message can be a string or a tuple. In case of a tuple, the second item can contain values for %-expansion of the message string. Expansion is performed only immediately prior to actually outputting the message, hence string formatting runtime costs can be avoided this way, if a message is not actually shown.

So code like

            return dict(
                action="meta_add",
                status="error",
                path=str(add_parameter.result_path),
                message=f'value of "dataset-id" '
                        f'({add_parameter.dataset_id}) does not match '
                        f'ID of dataset at {dataset_path} ({dataset_id})')

should be adjusted to not use f-strings.

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

No branches or pull requests

2 participants