Skip to content

Commit

Permalink
don't move the return value
Browse files Browse the repository at this point in the history
  • Loading branch information
andylokandy committed Aug 19, 2023
1 parent 1b9699b commit 4d9894e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "logcall"
version = "0.1.4"
edition = "2021"
authors = ["andylokandy <[email protected]>"]
description = "An attribute macro that logs the return value from function call."
description = "An attribute macro that logs the function return value."
repository = "https://github.com/andylokandy/logfn"
documentation = "https://docs.rs/logfn"
categories = ["development-tools::debugging"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# logcall

An attribute macro that logs the return value from function call.
An attribute macro that logs the function return value.

This is a reimplementation of the [`log-derive`](https://crates.io/crates/log-derive) crate with [`async-trait`](https://crates.io/crates/async-trait) compatibility.

Expand Down
6 changes: 3 additions & 3 deletions examples/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ fn foo(a: usize) -> usize {
}

#[logcall(err = "error")]
fn bar(a: usize) -> Result<usize, usize> {
Err(a + 1)
fn bar(a: usize) -> Result<usize, String> {
Err(format!("{}", a + 1))
}

#[logcall(ok = "info", err = "error")]
fn baz(a: usize) -> Result<usize, usize> {
fn baz(a: usize) -> Result<usize, String> {
Ok(a + 1)
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Args {
}
}

/// An attribute macro that logs the return values of functions.
/// An attribute macro that logs the function return value.
#[proc_macro_attribute]
#[proc_macro_error]
pub fn logcall(
Expand Down Expand Up @@ -270,7 +270,7 @@ fn gen_log(level: &str, fn_name: &str, return_value: &str) -> proc_macro2::Token
let level: Ident = Ident::new(&level, Span::call_site());
let return_value: Ident = Ident::new(return_value, Span::call_site());
quote!(
log::#level! ("{}() => {:?}", #fn_name, #return_value)
log::#level! ("{}() => {:?}", #fn_name, &#return_value)
)
}

Expand Down

0 comments on commit 4d9894e

Please sign in to comment.