log-derive
log-derive copied to clipboard
If function has a logger as parameter use it!
I've a function like this
fn get_something(log: Logger) -> Result<bool, Error> {
Ok(true)
}
I would like to use this awesome lib in order to log the error using the first parameter. For more generic usage
#[logfn(Err = "Error", fmt = "Failed Sending Packet: {:?}", logger = "my_obj.log")]
fn get_something(my_obj: MyObj) -> Result<bool, Error> {
Ok(true)
}
If you are interested, I may send a PR!
that's a nice add. I would hope there's a better UX to do this, but idk if that's possible.
Something like:
#[logfn(Err = "Error", fmt = "Failed Sending Packet: {:?}", my_obj)]
or similiar (without adding a new attribute)
I hope i'll have time this week to test this and maybe also release a new version (already changed some stuff and a bit of the API)
but if you want to play with this and update me that's more than welcome :)
I'm not so familiar with quore!
macro. I've tried to implement but some compile errors appears. Could you suggest me some tools for debugging?
Thanks
Oh, wait, you want to pass a logger not an attribute.
Is the Logger behaving the some as rust's log
?
Can you show me a real example of this?
Actually I'm using https://docs.rs/sloggers/0.3.2/sloggers/ because I would have different loggers.
An example of usage can be found here: https://github.com/slog-rs/misc/blob/master/examples/features.rs. The primary feature of this kind of logger is the child
: you can create a logger adding some info to it. That infos are printed in every log line.
I would like to use that kind of instance here.
Are you interested?
hmmmm this is a totally different facade.
I'm using log
and you want slog
compatibility.
this won't be easily done without feature gating or a separate crate.