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

async functions compatibility #20

Closed D1plo1d closed 4 years ago

D1plo1d commented 4 years ago

It would be great if we could use log-derive with async functions. Adding logfn to an async function gives me the following:

error[E0728]: `await` is only allowed inside `async` functions and blocks
  --> src/models/video/mod.rs:94:9
   |
44 | #[logfn(ok = "INFO", err = "ERROR")]
   | ------------------------------------ this is not `async`
...
94 |         task::sleep(std::time::Duration::from_millis(500)).await;
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ only allowed inside `async` functions and blocks

Source Snippet:

#[logfn(ok = "INFO", err = "ERROR")]
pub async fn create_video_sdp() {
// ...