Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: apply MSRV 1.80.0 #15

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 50 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,55 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: ubuntu-latest
check:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install Stable Rust
run: rustup toolchain install stable
- name: Use Stable Rust
run: rustup default stable
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Run example
run: cargo run --example main
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
with:
components: rustfmt,clippy
- uses: Swatinem/rust-cache@v2
- name: Check clippy
run: cargo +nightly clippy --all-targets --all-features -- -D warnings
- name: Check format
run: cargo +nightly fmt --all -- --check

test:
strategy:
matrix:
rust-version: [ "1.80.0", "stable" ]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: Swatinem/rust-cache@v2
- name: Delete rust-toolchain.toml
run: rm rust-toolchain.toml
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust-version }}
- name: Build
run: cargo build --all-features --tests --examples --lib
- name: Run unit tests
run: cargo test --all-features -- --nocapture
- name: Run examples
run: cargo run --example main

required:
name: Required
runs-on: ubuntu-22.04
if: ${{ always() }}
needs:
- check
- test
steps:
- name: Guardian
run: |
if [[ ! ( \
"${{ needs.check.result }}" == "success" \
&& "${{ needs.test.result }}" == "success" \
) ]]; then
echo "Required jobs haven't been completed successfully."
exit -1
fi
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name = "logcall"
version = "0.1.11"
edition = "2021"
rust-version = "1.80.0"
description = "An attribute macro that logs the function return value."
repository = "https://github.com/fast/logcall"
documentation = "https://docs.rs/logcall"
Expand Down
4 changes: 1 addition & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
The MIT License (MIT)

Copyright (c) 2023 FastLabs Developers
Copyright (c) 2023-2025 FastLabs Developers

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# logcall
# Logcall

[![Crates.io](https://img.shields.io/crates/v/logcall?style=flat-square&logo=rust)](https://crates.io/crates/logcall)
[![Downloads](https://img.shields.io/crates/d/logcall?style=flat-square&logo=rust)](https://crates.io/crates/logcall)
[![Documentation](https://img.shields.io/docsrs/logcall?style=flat-square&logo=rust)](https://docs.rs/logcall/)
[![CI Status](https://img.shields.io/github/actions/workflow/status/fast/logcall/ci.yml?style=flat-square&logo=github)](https://github.com/fast/logcall/actions)
[![License](https://img.shields.io/crates/l/logcall?style=flat-square&logo=)](https://crates.io/crates/logcall)

`logcall` is a Rust procedural macro crate designed to automatically log function calls, their inputs, and their outputs. This macro facilitates debugging and monitoring by providing detailed logs of function executions with minimal boilerplate code.
Logcall is a Rust procedural macro crate designed to automatically log function calls, their inputs, and their outputs. This macro facilitates debugging and monitoring by providing detailed logs of function executions with minimal boilerplate code.

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

Expand Down Expand Up @@ -115,10 +115,16 @@ When the `main` function runs, it initializes the logger and logs each function
#[logcall(ok = "info", err = "error", input = "a = {a:?}, ..")]
```

## Minimum Supported Rust Version (MSRV)

This crate is built against the latest stable release, and its minimum supported rustc version is 1.80.0.

The policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if Logcall 1.0 requires Rust 1.20.0, then Logcall 1.0.z for all values of z will also require Rust 1.20.0 or newer. However, Logcall 1.y for y > 0 may require a newer minimum version of Rust.

## Contributing

Contributions are welcome! Please submit pull requests or open issues to improve the crate.

## License

This project is licensed under the MIT License.
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
10 changes: 7 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#![doc = include_str!("../README.md")]

// Instrumenting the async fn is not as straight forward as expected because `async_trait` rewrites `async fn`
// into a normal fn which returns `Box<impl Future>`, and this stops the macro from distinguishing `async fn` from `fn`.
// The following code reused the `async_trait` probes from [tokio-tracing](https://github.com/tokio-rs/tracing/blob/6a61897a5e834988ad9ac709e28c93c4dbf29116/tracing-attributes/src/expand.rs).
// Instrumenting the async fn is not as straight forward as expected because `async_trait`
// rewrites `async fn` into a normal fn which returns `Box<impl Future>`, and this stops
// the macro from distinguishing `async fn` from `fn`.
//
// The following code reused the `async_trait` probes from tokio-tracing [1].
//
// [1] https://github.com/tokio-rs/tracing/blob/6a61897a/tracing-attributes/src/expand.rs

use proc_macro2::Span;
use proc_macro_error2::abort_call_site;
Expand Down
Loading