Open
Conversation
Xuanwo
reviewed
Jun 16, 2025
| /// corresponding overhead. | ||
| pub(crate) fn enable_tracing_integration(rados: rados_t) -> RadosResult<()> { | ||
| let (level_str, opt_log_callback): (&[u8], rados_log_callback_t) = { | ||
| if event_enabled!(target: "librados", Level::ERROR) { |
Collaborator
There was a problem hiding this comment.
Hi, I assume you're writing this way to minimize the runtime cost of additional checks. However, the enable API itself is usually not a heavy call. How about expanding them into one place within the loop?
for example:
type RadosLogCallback = rados_log_callback_t;
fn librados_log_level() -> (&'static [u8], Option<RadosLogCallback>) {
const CANDIDATES: &[(Level, &[u8])] = &[
(Level::DEBUG, b"debug\0"),
(Level::INFO, b"info\0"),
(Level::WARN, b"warn\0"),
(Level::ERROR, b"error\0"),
];
for &(lvl, cstr) in CANDIDATES {
if event_enabled!(target: "librados", lvl) {
return (cstr, Some(log_callback));
}
}
(b"\0", None)
}
Contributor
Author
There was a problem hiding this comment.
I think that is not possible because these macros require const level, like below.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Plugs
librados' logs astracingevents, so that they can be seen by users.