Skip to content
forked from fast/logcall

An attribute macro that logs the function return value

License

Notifications You must be signed in to change notification settings

cloudwalk/logcall

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

logcall

An attribute macro that logs the function input & return values.

This is a reimplementation of the log-derive crate with async-trait compatibility.

Usage

use logcall::logcall;

#[logcall("info")]
fn foo(a: usize) -> usize {
    a + 1
}

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

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

fn main() {
    structured_logger::Builder::new().init();
    foo(1);
    bar(1).ok();
    baz(1).ok();
}

// prints:
// [2023-07-22T06:55:10Z INFO  main] foo() => 2
// [2023-07-22T06:55:10Z ERROR main] bar() => Err(2)
// [2023-07-22T06:55:10Z INFO  main] baz() => Ok(2)

About

An attribute macro that logs the function return value

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 100.0%