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

feat: Add only_parameter and exclude_parameter to @debug decorator #17

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

sveneberth
Copy link
Member

No description provided.

@sveneberth sveneberth added Priority: Medium This issue may be useful, and needs some attention. enhancement New feature or request labels Sep 4, 2024
@sveneberth sveneberth added the version-target:minor This change is scheduled for the next minor version label Sep 4, 2024
# Add ellipsis in the middle to indicate omitted parameters
kwargs_repr.insert(len(kwargs_repr) // 2, "[...]")
signature = ", ".join(kwargs_repr)
logger.info(f"CALLING {func.__name__}({signature})")

Choose a reason for hiding this comment

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

Suggested change
logger.info(f"CALLING {func.__name__}({signature})")
logger.debug(f"CALLING {func.__name__}({signature})")

Why we don't use the debug logger if the decorator is called @debug

Copy link
Member Author

Choose a reason for hiding this comment

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

On the one hand because the default level of the viur-toolkit is info and a debug log is only displayed after manually lowering the level. Then you would use the debug decorator and see nothing. To avoid confusion and not having to switch a second lever to get the desired output, this is info.

Furthermore, debug logs are there to get low-level information (regarding the behavior) of a software. Here, however, the aim is not to obtain information within the viur-toolkit, but to obtain information at the high-level user level of the viur-toolkit. Hence info.

The correct way would be that the project would have to pass or pre-configure the project logger here. But IMO that goes way too far for a small helper.

value = func(*args, **kwargs)
logging.info(f"{func.__name__} RETURNED {value}")
logger.info(f"{func.__name__} RETURNED {value!r}")

Choose a reason for hiding this comment

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

Suggested change
logger.info(f"{func.__name__} RETURNED {value!r}")
logger.debug(f"{func.__name__} RETURNED {value!r}")

Here too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Priority: Medium This issue may be useful, and needs some attention. version-target:minor This change is scheduled for the next minor version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants