From 22a12a140f46911175d9efeb781de7af88008526 Mon Sep 17 00:00:00 2001 From: tison Date: Tue, 28 Jan 2025 18:45:31 +0800 Subject: [PATCH] chore: apply MSRV 1.80.0 (#15) Signed-off-by: tison --- .github/workflows/ci.yml | 62 ++++++++++++++++++++++++++++++++-------- Cargo.toml | 1 + LICENSE | 4 +-- README.md | 12 ++++++-- src/lib.rs | 10 +++++-- 5 files changed, 68 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4cd2c0f..be27530 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/Cargo.toml b/Cargo.toml index cbfe854..66e0025 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/LICENSE b/LICENSE index 9ffaaba..7e3711c 100644 --- a/LICENSE +++ b/LICENSE @@ -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 diff --git a/README.md b/README.md index 9089938..d954eb0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 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) @@ -6,7 +6,7 @@ [![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. @@ -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. diff --git a/src/lib.rs b/src/lib.rs index 453c4d4..806c712 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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`, 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`, 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;