-
Notifications
You must be signed in to change notification settings - Fork 305
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
aya-log panics when logging [u8;6] without format argument #513
Comments
@vadorovsky when you get a chance could you look into this? |
@alessandrod @vadorovsky Hi, I think I understand why the error was thrown. Firstly, the Lines 191 to 195 in 23ce42d
This writes the type of the field and some other information, which is then retrieved when formatting the string, as shown here: Lines 463 to 465 in 23ce42d
Because Lines 217 to 231 in 23ce42d
And currently, it seems that only |
Please give me some feedback. If it would be helpful, I would be happy to take on the responsibility of addressing this issue. |
I think the issue is here Line 115 in 23ce42d
|
Indeed,
impl Formatter<[u8; 6]> for DefaultFormatter; {
fn format(v: [u8; 6]) -> String {
// e.g.
format!("{:?}", v)
}
}
Here is an example code that moves the error timing to compile time: |
@Hanaasagi that's right, thanks for debugging that! I think we shouldn't support
So I like your second option - moving the error to proc macro. Happy to see that you started working on it! Would you like to submit a pull request? |
Sure, I will open a pull request to validate this in proc macro. |
Using aya-log to log a
[u8;6]
compiles and leads to a runtime panic if no format argument (e.g.:mac
) is provided.Example:
info!(&ctx, "received a packet: {}", [0_u8;6]);
Error:
thread 'tokio-runtime-worker' panicked at 'called `Result::unwrap()` on an `Err` value: ()', /home/arctic-alpaca/.cargo/registry/src/github.com-1ecc6299db9ec823/aya-log-0.1.13/src/lib.rs:110:45
Used a newly created xdp project from the template to reproduce.
The text was updated successfully, but these errors were encountered: