elichai / log-derive

A procedural macro for auto logging output of functions
https://docs.rs/log-derive
Apache License 2.0
189 stars 12 forks source link

Support multiple arguments output #1

Closed Michael-Lfx closed 5 years ago

Michael-Lfx commented 5 years ago

Nice work! Is that any plan to support multiple arguments output? Here is a failed test.

#[logfn(INFO, fmt = "foo(n: {}, m: {})")]
fn foo(n: u32, m: f32) {
    println!("hello");
}
elichai commented 5 years ago

Hmm, do you mean a function that returns a tuple?

Because your example returns nothing, and right now there's no support to logging the inputs of a function, only the outputs. (although I want to add, just need to decide if it should be in a separate macro or not)

Michael-Lfx commented 5 years ago

Thank you for reply so quickly. I want to log function call with all its parameters not only parameter name but also actual parameter value.

elichai commented 5 years ago

I don't really understand exactly do you want, right now the macro let's you log only the output of a function, are you looking for input value support? e.g.

#[logfn(DEBUG)]
fn foo(a: A, b: B) -> C {
    return C;
}

This will log only C, not a or b. I think what you're looking for is to log a and b, right? (maybe the fibonacci example was a bit confusing)

Michael-Lfx commented 5 years ago

I think what you're looking for is to log a and b, right?

Yes. To log function name and its parameters with their runtime value also.

elichai commented 5 years ago

Ok, yeah I plan to implement this in the next few days. I mostly need to decide if this should be in the same macro or different one

elichai commented 5 years ago

For anyone interested that's done :) I'll publish a new version today.