stevenliebregt / fun_time

Time your Rust functions!
MIT License
5 stars 0 forks source link

Allow to print also function name #8

Open qarmin opened 1 year ago

qarmin commented 1 year ago

Currently with such macro

    #[fun_time(message = "Heavy calculations on: {stop_receiver:?}")]
    pub fn find_bad_extensions_files(&mut self, stop_receiver: Option<&Receiver<()>>, progress_sender: Option<&UnboundedSender<ProgressData>>) {

I got this messages

21:19:14.762 [INFO] czkawka_core::bad_extensions: Heavy calculations on: Some(Receiver { .. })
21:19:14.803 [INFO] czkawka_core::bad_extensions: Heavy calculations on: Some(Receiver { .. }): Done in 40.66ms

but would be great to see also function name without needing to manually put there function name

https://github.com/y2kappa/timed - already have such functionality, but produced string is ugly

function=get_random_quote duration=455.291753ms
function=main duration=456.452412ms
stevenliebregt commented 1 year ago

How would you like to see this work?

Since the logging message is solely powered by the built-in format! macro and no manual parsing is done, it could be as easy as exposing a fn_name string in case the message string looks like this for example: message = "Heavy calculations in function: {fn_name} or would someting like an extra option to the macro like show_fn = true be preferred, which would produce a message like [find_bad_extensions_files] Heavy calculations ...