From 647409aacf9383f407825fe39d577238127848b1 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 20 Aug 2025 18:25:12 +0200 Subject: [PATCH 1/5] ci: Use ubuntu-latest instead of ubuntu-20.04 --- .github/workflows/ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ab9291b..0a98d9e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,8 +46,7 @@ jobs: matrix: rust: - stable - # ubuntu-latest still points to 18.04, which only has QEMU 2 - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 From 405ad61d6cc2c16df474eed43d66d0b2b689f0fc Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 20 Aug 2025 18:28:19 +0200 Subject: [PATCH 2/5] Fix or allow new clippy lints --- src/hex.rs | 2 +- src/lib.rs | 2 ++ src/render.rs | 22 +--------------------- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/src/hex.rs b/src/hex.rs index 3b49ade..69149f0 100644 --- a/src/hex.rs +++ b/src/hex.rs @@ -184,7 +184,7 @@ macro_rules! hexstr { /// /// assert_eq!(format!("{}", hex_str), "07A1FF|C7"); /// ``` -pub fn HexStr(value: &T) -> HexStr { +pub fn HexStr(value: &T) -> HexStr<'_, T, U, S> { HexStr { value, _bytes_per_block: PhantomData, diff --git a/src/lib.rs b/src/lib.rs index 5b0e009..f9316d7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -141,6 +141,8 @@ static mut LOGGER: Option<&'static dyn logger::TryLogWithStatistics> = None; /// Returns a reference to the logger (as `TryLogWithStatistics` implementation) pub fn logger() -> &'static mut Option<&'static dyn logger::TryLogWithStatistics> { + // TODO: implement safe alternative + #[allow(static_mut_refs)] unsafe { &mut LOGGER } } diff --git a/src/render.rs b/src/render.rs index d374670..2cce99b 100644 --- a/src/render.rs +++ b/src/render.rs @@ -16,27 +16,7 @@ pub fn render_arguments<'a>(buf: &'a mut [u8], args: fmt::Arguments) -> &'a [u8] /// Render record, based on feature flags. pub fn render_record<'a>(buf: &'a mut [u8], record: &log::Record) -> &'a [u8] { - if cfg!(feature = "prefix-level") { - match (record.file(), record.line()) { - (Some(file), Some(line)) => render_arguments( - buf, - format_args!( - "{}|{}|{}:{}: {}", - record.level(), - record.target(), - file, - line, - record.args() - ), - ), - _ => render_arguments( - buf, - format_args!("{}|{}: {}", record.level(), record.target(), record.args()), - ), - } - } else { - render_arguments(buf, *record.args()) - } + render_arguments(buf, *record.args()) } // I don't get it, why isn't this implemented already? From 56157c9a1792701a27c2e5f1d5bc0aea381b548a Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 20 Aug 2025 18:06:31 +0200 Subject: [PATCH 3/5] Add CI job for thumbv6m-none-eabi --- .github/workflows/ci.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0a98d9e..2026889 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,6 +41,17 @@ jobs: - name: Run non-QEMU tests run: make non-qemu-tests + build-thumbv6m-none-eabi: + runs-on: ubuntu-latest + env: + CARGO_BUILD_TARGET: thumbv6m-none-eabi + steps: + - uses: actions/checkout@v2 + - name: Install rust + run: rustup target add ${CARGO_BUILD_TARGET} + - name: Build + run: cargo build + qemu-test: strategy: matrix: From f7398330048d2119f7d343ed86319e817501e0e5 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 20 Aug 2025 18:19:11 +0200 Subject: [PATCH 4/5] Add optional support for portable-atomic Fixes: https://github.com/trussed-dev/delog/issues/9 --- .github/workflows/ci.yml | 2 +- CHANGELOG.md | 1 + Cargo.toml | 1 + src/logger.rs | 7 ++++++- 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2026889..ee090b9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -50,7 +50,7 @@ jobs: - name: Install rust run: rustup target add ${CARGO_BUILD_TARGET} - name: Build - run: cargo build + run: cargo build --features portable-atomic,portable-atomic/critical-section qemu-test: strategy: diff --git a/CHANGELOG.md b/CHANGELOG.md index d58d8e0..47fd0e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +- add `portable-atomic` feature to replace `core::sync::atomic::AtomicUsize` with `portable_atomic::AtomicUsize` ## [0.1.7] - 2023-08-17 - fix breakage caused by using internal `log` APIs diff --git a/Cargo.toml b/Cargo.toml index 020d9c8..947a28f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ targets = [] [dependencies] log = "0.4" +portable-atomic = { version = "1", optional = true } [dev-dependencies] insta = "1.7" diff --git a/src/logger.rs b/src/logger.rs index 22dd668..9ae4207 100644 --- a/src/logger.rs +++ b/src/logger.rs @@ -1,6 +1,11 @@ -use core::sync::atomic::{AtomicUsize, Ordering}; +use core::sync::atomic::Ordering; use core::{cmp, ptr}; +#[cfg(not(feature = "portable-atomic"))] +use core::sync::atomic::AtomicUsize; +#[cfg(feature = "portable-atomic")] +use portable_atomic::AtomicUsize; + /// Semi-abstract characterization of the deferred loggers that the `delog!` macro produces. /// /// # Safety From 03709e1800831b7c0186b48c36bc41668e105804 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Wed, 20 Aug 2025 18:33:05 +0200 Subject: [PATCH 5/5] Release v0.1.8 --- CHANGELOG.md | 2 ++ Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 47fd0e3..113726a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] + +## [0.1.8] - 2025-08-21 - add `portable-atomic` feature to replace `core::sync::atomic::AtomicUsize` with `portable_atomic::AtomicUsize` ## [0.1.7] - 2023-08-17 diff --git a/Cargo.toml b/Cargo.toml index 947a28f..d3de931 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "delog" -version = "0.1.7" +version = "0.1.8" description = "Deferred logging, an implementation and extension of Rust's standard logging facade." authors = ["Trussed Developers"] license = "Apache-2.0 OR MIT"