Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 an optional logger param #664
base: master
Are you sure you want to change the base?
Add an optional logger param #664
Changes from 5 commits
d5061b6
2851f2b
a3f72c8
dd835fe
c300df0
cde2585
2bb47d6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default logger should be a zero sized type, otherwise caller needs pay the cost of passing the logger value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. I get your point now. Let me update it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check if this is what you mean 2bb47d6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just a good target to test our new
logger
param.Previously, the global logger state is shared with all the
macros
tests and causes the result unstable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if we call a log macro with
logger
param here? The macro would expand alet logger = $logger;
, which seems to move rather than borrow the logger variable.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC it would be
debug!(logger: &logger, ...)
then. That is, use ref from the user size.One of the rationales is @EFanZh's comment about "binary size", see:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we'd need to document this behavior. We have a hierarchy of level controls; at compile time, at runtime, and whatever the logger itself applies. We should be clear that these are features of the macros, so apply equally regardless of the logger you plug in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please elaborate a bit what to be documented and where I should add the docs?
It seems that you'd like to emphasize that these macros can be compiled to nop if the related flags (e.g.,
max_level_error
,release_max_level_error
, etc.) enabled.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This inspires me to consider whether we should export the NopLogger ..