Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9adfc8e
Update documentation for `StringBuf`
SpriteOvO Oct 30, 2025
e2aa6d3
Enable Rustdoc examples scraping on docs.rs
SpriteOvO Oct 30, 2025
cf3a3dd
Flush sinks on program exit with a special method `flush_on_exit` (#102)
tisonkun Nov 3, 2025
771243d
Hint at connection between "verbose" and `LevelFilter::All` in example
SpriteOvO Nov 3, 2025
7c86694
Deprecate `AsyncPoolSinkBuilder::formatter` method
SpriteOvO Nov 12, 2025
e4444c8
Add a shorthand method `build_arc` to builder structs (#107)
SpriteOvO Nov 15, 2025
bd59ff0
Add `justfile`
SpriteOvO Nov 15, 2025
9a91ddd
Improve builder structs doc, add default values to methods doc
SpriteOvO Nov 16, 2025
afd0df7
Inherit the same package properties from workspace
SpriteOvO Nov 22, 2025
065c964
Rename feature gate `test` to `std-stream-captured`
SpriteOvO Nov 26, 2025
5d95b07
Cargo check tests and examples
SpriteOvO Nov 27, 2025
a619332
Use `from` instead of `capture` for KV values (#109)
SpriteOvO Nov 27, 2025
3353acc
Rename `crates-io.md` to `README.md` for `spdlog-{macros,internal}`
SpriteOvO Nov 27, 2025
8bc177d
Introduce `PartialFormatter` to allow selection of formatting parts
SpriteOvO Nov 22, 2025
25e6b36
Replace private `JournaldFormatter` with `PartialFormatter`
SpriteOvO Nov 23, 2025
ba27645
Replace private `AndroidFormatter` with `PartialFormatter`
SpriteOvO Nov 23, 2025
12ec0e6
Rename `PartialFormatter` to `OptFormatter`
SpriteOvO Nov 27, 2025
aca535d
Add documentation for `OptFormatter`
SpriteOvO Nov 27, 2025
c36ca9c
CI Fix flaky Windows native test
SpriteOvO Nov 29, 2025
8fc2296
Make `Level::count` method public
SpriteOvO Nov 29, 2025
7c107c2
Move CI native tests code to separate scripts
SpriteOvO Nov 29, 2025
a96e69f
CI Read `rust-version` from `Cargo.toml`
SpriteOvO Dec 5, 2025
5e267de
Add doc entry "Capturing logs in tests" to "Overview of features"
SpriteOvO Dec 5, 2025
bed493d
Allow setting up filter for records from `log` crate
SpriteOvO Dec 5, 2025
faffb0a
Bump MSRV to 1.71
SpriteOvO Dec 5, 2025
af0a912
Introduce `AtomicLevelFilter`
SpriteOvO Nov 29, 2025
704cf7e
Bump `atomic` dependency to the latest
SpriteOvO Nov 29, 2025
fa8d098
Move assertions for `Level{,Filter{,Layout}}` out of `cfg(test)`
SpriteOvO Dec 8, 2025
21534f4
Refactor `LevelFilterLayout` to avoid unsafe code
SpriteOvO Dec 9, 2025
3606359
Make `just doc --open` open `spdlog-rs` instead of `spdlog-internal`
SpriteOvO Dec 17, 2025
30d4b0f
Add benchmark for `OptFormatter`
SpriteOvO Dec 17, 2025
bbe5a00
Merge `OptFormatter` into `FullFormatter`
SpriteOvO Dec 17, 2025
e78cb56
Mark logging macros with `#[clippy::format_args]` attribute
SpriteOvO Dec 18, 2025
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
125 changes: 39 additions & 86 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ on:

env:
CARGO_TERM_COLOR: always
# When updating this, also update:
# - src/lib.rs
# - Cargo.toml
# - README.md
rust_minver: 1.66.1
ci_targets: "['x86_64-unknown-linux-gnu', 'x86_64-pc-windows-msvc', 'aarch64-apple-darwin', 'x86_64-apple-ios', 'x86_64-unknown-freebsd', 'x86_64-unknown-illumos', 'aarch64-linux-android']"

defaults:
Expand Down Expand Up @@ -47,22 +42,25 @@ jobs:
uses: actions/checkout@v4
- name: Disable bench dependencies
run: ./.github/workflows/disable-bench-deps.sh
- uses: extractions/setup-just@v3
- name: Install Rust nightly
run: |
rustup toolchain install nightly
rustup component add rustfmt --toolchain nightly
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo +nightly fmt --all --verbose -- --check
- name: Check Rust formatting
run: just fmt --verbose -- --check
- name: Check justfile formatting
run: just --unstable --fmt --check

test:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
fn_features: ['', 'log native libsystemd multi-thread runtime-pattern serde serde_json sval']
cfg_feature: ['', 'flexible-string', 'source-location', 'test']
cfg_feature: ['', 'flexible-string', 'source-location', 'std-stream-captured']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
Expand All @@ -75,13 +73,17 @@ jobs:
timezoneWindows: "China Standard Time"
- name: Disable bench dependencies
run: ./.github/workflows/disable-bench-deps.sh
- uses: extractions/setup-just@v3
- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo bash ./.github/workflows/install-deps.sh
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Run tests
- name: Run tests with selected features
run: cargo test --features "${{ matrix.fn_features }} ${{ matrix.cfg_feature }}" --verbose
- name: Run tests with all features
if: matrix.fn_features == '' && matrix.cfg_feature == ''
run: just test
- name: Run examples
if: matrix.fn_features != ''
run: |
Expand All @@ -102,6 +104,7 @@ jobs:
- name: Disable bench dependencies
if: matrix.target != fromJSON(needs.matrix.outputs.ci_targets)[0]
run: ./.github/workflows/disable-bench-deps.sh
- uses: extractions/setup-just@v3
- name: Install dependencies
run: sudo bash ./.github/workflows/install-deps.sh
- name: Install Rust nightly
Expand All @@ -116,7 +119,7 @@ jobs:
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Run clippy
run: cargo clippy --all-features --tests --examples -- -D warnings
run: just clippy -- -D warnings
- name: Run clippy nightly
run: |
cargo +nightly clippy --all-features --tests --examples
Expand Down Expand Up @@ -148,6 +151,7 @@ jobs:
uses: actions/checkout@v4
- name: Disable bench dependencies
run: ./.github/workflows/disable-bench-deps.sh
- uses: extractions/setup-just@v3
- name: Install dependencies
run: sudo bash ./.github/workflows/install-deps.sh
- name: Install Rust target
Expand All @@ -157,7 +161,7 @@ jobs:
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Run check
run: cargo check --all-features --verbose
run: just check --verbose

check-doc:
strategy:
Expand All @@ -168,6 +172,7 @@ jobs:
uses: actions/checkout@v4
- name: Disable bench dependencies
run: ./.github/workflows/disable-bench-deps.sh
- uses: extractions/setup-just@v3
- name: Install dependencies
run: sudo bash ./.github/workflows/install-deps.sh
- name: Install Rust nightly
Expand All @@ -176,12 +181,11 @@ jobs:
uses: Swatinem/rust-cache@v2
- name: Run rustdoc nightly
run: |
cd spdlog
cargo +nightly rustdoc --verbose -- -D warnings -A rustdoc::broken-intra-doc-links
cargo +nightly rustdoc --all-features --verbose -- -D warnings
cd ../spdlog-macros
cargo +nightly rustdoc --verbose -- -D warnings -A rustdoc::broken-intra-doc-links
cargo +nightly rustdoc --all-features --verbose -- -D warnings
RUSTDOCFLAGS='-D warnings -A rustdoc::broken-intra-doc-links'
just _doc-default-features --verbose

RUSTDOCFLAGS='-D warnings'
just doc --verbose

check-msrv:
needs: [matrix]
Expand All @@ -199,12 +203,17 @@ jobs:
run: sudo bash ./.github/workflows/install-deps.sh
- name: Install Rust nightly
run: rustup toolchain install nightly
- name: Install Rust ${{ env.rust_minver }}
run: rustup toolchain install ${{ env.rust_minver }}
- name: Read rust-version from Cargo.toml
run: |
MSRV=$(yq '.workspace.package.rust-version' ./Cargo.toml)
echo $MSRV
echo "MSRV=$MSRV" >> $GITHUB_ENV
- name: Install Rust ${{ env.MSRV }}
run: rustup toolchain install ${{ env.MSRV }}
- name: Install Rust target
run: |
rustup target add ${{ matrix.target }} --toolchain nightly
rustup target add ${{ matrix.target }} --toolchain ${{ env.rust_minver }}
rustup target add ${{ matrix.target }} --toolchain ${{ env.MSRV }}
echo 'CARGO_BUILD_TARGET=${{ matrix.target }}' >> $GITHUB_ENV
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
Expand All @@ -215,8 +224,8 @@ jobs:
perl -pi -e 's/\[dev-dependencies]/[workaround-avoid-dev-deps]/g' ./spdlog/Cargo.toml
- name: Downgrade dependencies to minimal versions
run: cargo +nightly update -Z minimal-versions
- name: Check MSRV for core with Rust ${{ env.rust_minver }}
run: cargo +${{ env.rust_minver }} check --locked --all-features --verbose
- name: Check MSRV for core with Rust ${{ env.MSRV }}
run: cargo +${{ env.MSRV }} check --locked --all-features --verbose

test-native-linux:
strategy:
Expand All @@ -232,28 +241,9 @@ jobs:
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Build example
run: |
cargo build --example native_linux --features native,libsystemd,source-location --verbose
mv ./target/debug/examples/native_linux ./target/debug/examples/native_linux_srcloc
cargo build --example native_linux --features native,libsystemd --verbose
run: bash ./spdlog/tests/native/linux.sh build
- name: Run and test
run: |
set -x
./target/debug/examples/native_linux
./target/debug/examples/native_linux_srcloc

journalctl --no-pager -o verbose -t native_linux
journalctl --no-pager -o verbose -t native_linux_srcloc

journalctl --no-pager -o json -t native_linux | jq -e -s $'.[0].MESSAGE == "[demo] [info] info message from spdlog-rs\'s JournaldSink\n"'
journalctl --no-pager -o json -t native_linux | jq -e -s $'.[0].PRIORITY == "6" and .[0].CODE_FILE == null and .[0].CODE_LINE == null and .[0].TID != null'
journalctl --no-pager -o json -t native_linux | jq -e -s $'.[1].MESSAGE == "[demo] [error] error message from spdlog-rs\'s JournaldSink { error_code=114514 }\n"'
journalctl --no-pager -o json -t native_linux | jq -e -s $'.[1].PRIORITY == "3" and .[1].CODE_FILE == null and .[1].CODE_LINE == null and .[1].TID != null'

journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[0].MESSAGE == "[demo] [info] info message from spdlog-rs\'s JournaldSink\n"'
journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[0].PRIORITY == "6" and .[0].CODE_FILE == "linux.rs" and .[0].CODE_LINE == "15" and .[0].TID != null'
journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[1].MESSAGE == "[demo] [error] error message from spdlog-rs\'s JournaldSink { error_code=114514 }\n"'
journalctl --no-pager -o json -t native_linux_srcloc | jq -e -s $'.[1].PRIORITY == "3" and .[1].CODE_FILE == "linux.rs" and .[1].CODE_LINE == "16" and .[1].TID != null'
run: bash ./spdlog/tests/native/linux.sh run

test-native-windows:
strategy:
Expand All @@ -269,31 +259,9 @@ jobs:
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Build example
run: |
cargo build --example native_windows --features native,source-location --verbose
mv ./target/debug/examples/native_windows ./target/debug/examples/native_windows_srcloc
cargo build --example native_windows --features native --verbose
run: bash ./spdlog/tests/native/windows.sh build
- name: Run and test
run: |
set -x

# Microsoft styled CLI options start with `/` and need to be doubled to escape in bash.
dbgview //l ./dbgview.log
# Wait for dbgview to start up and create the log file
while [ ! -f ./dbgview.log ]; do sleep 1; done

./target/debug/examples/native_windows
./target/debug/examples/native_windows_srcloc

# Wait for dbgview to flush the log file
while [ ! -s ./dbgview.log ]; do sleep 1; done
dbgview //q

cat ./dbgview.log
cat ./dbgview.log | grep "\[demo] \[info] info message from spdlog-rs's WinDebugSink"
cat ./dbgview.log | grep "\[demo] \[error] error message from spdlog-rs's WinDebugSink { error_code=114514 }"
cat ./dbgview.log | grep -E "\[demo] \[info] \[native_windows, .+.rs:[0-9]+] info message from spdlog-rs's WinDebugSink"
cat ./dbgview.log | grep -E "\[demo] \[error] \[native_windows, .+.rs:[0-9]+] error message from spdlog-rs's WinDebugSink { error_code=114514 }"
run: bash ./spdlog/tests/native/windows.sh run

test-native-android:
strategy:
Expand All @@ -309,10 +277,7 @@ jobs:
- name: Install cross
run: cargo install cross --git https://github.com/cross-rs/cross --verbose
- name: Build example
run: |
cross build --target x86_64-linux-android --example native_android --features native,android-ndk,source-location --verbose
mv ./target/x86_64-linux-android/debug/examples/native_android ./target/x86_64-linux-android/debug/examples/native_android_srcloc
cross build --target x86_64-linux-android --example native_android --features native,android-ndk --verbose
run: bash ./spdlog/tests/native/android.sh build
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
Expand All @@ -323,20 +288,7 @@ jobs:
with:
api-level: 29
arch: x86_64
script: |
adb root
adb push ./target/x86_64-linux-android/debug/examples/native_android /data
adb push ./target/x86_64-linux-android/debug/examples/native_android_srcloc /data

adb logcat -b all -c
adb shell /data/native_android
adb shell /data/native_android_srcloc
adb logcat -s "spdlog-rs-example" -d > ./logcat.log
cat ./logcat.log
cat ./logcat.log | grep "I spdlog-rs-example: \[demo] info message from spdlog-rs's AndroidSink"
cat ./logcat.log | grep "E spdlog-rs-example: \[demo] error message from spdlog-rs's AndroidSink { error_code=114514 }"
cat ./logcat.log | grep -E "I spdlog-rs-example: \[demo] \[native_android, .+.rs:[0-9]+] info message from spdlog-rs's AndroidSink"
cat ./logcat.log | grep -E "E spdlog-rs-example: \[demo] \[native_android, .+.rs:[0-9]+] error message from spdlog-rs's AndroidSink { error_code=114514 }"
script: bash ./spdlog/tests/native/android.sh run

bench:
needs: [test, check]
Expand All @@ -348,13 +300,14 @@ jobs:
uses: actions/checkout@v4
- name: Disable bench dependencies
run: ./.github/workflows/disable-bench-deps.sh
- uses: extractions/setup-just@v3
- name: Install Rust nightly
run: rustup toolchain install nightly
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Run benchmark
run: |
cargo +nightly bench --features "multi-thread,runtime-pattern,serde_json,log" \
just bench \
--bench spdlog_rs \
--bench spdlog_rs_pattern \
--bench spdlog_rs_log_crate_proxy \
Expand Down
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ members = [
"spdlog-internal",
"spdlog-macros",
]

[workspace.package]
edition = "2021"
rust-version = "1.71" # When updating this, also update: src/lib.rs, README.md
repository = "https://github.com/SpriteOvO/spdlog-rs"
license = "MIT OR Apache-2.0"
keywords = ["spdlog", "log", "logging"]
categories = ["development-tools::debugging"]
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ Unreleased commits are active on [`main-dev`] branch, and [`main`] branch is onl

If you are going to contribute `spdlog-rs`, please make sure to check out the [`main-dev`] branch and select the [`main-dev`] branch as the base when opening PR.

Due to the complexity of combining crate feature gates, this repository provides a [./justfile] for tool [`just`] to easily interact with `cargo` during development. Run command `just --list` to check the available recipes specifically for this project.

## Supported Rust versions

<!--
Expand All @@ -54,7 +56,7 @@ When updating this, also update:
- Cargo.toml
-->

The current minimum supported Rust version is 1.66.1.
The current minimum supported Rust version is 1.71.

`spdlog-rs` is built against the latest Rust stable release, it is not guaranteed to build on Rust versions earlier than the minimum supported version.

Expand Down Expand Up @@ -82,3 +84,5 @@ Unless you explicitly state otherwise, any contribution intentionally submitted
[open an issue]: https://github.com/SpriteOvO/spdlog-rs/issues/new/choose
[`main-dev`]: https://github.com/SpriteOvO/spdlog-rs/tree/main-dev
[`main`]: https://github.com/SpriteOvO/spdlog-rs/tree/main
[./justfile]: /justfile
[`just`]: https://github.com/casey/just
42 changes: 42 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
just := 'just' + ' --justfile=' + justfile()

_:
@{{ just }} --list

alias format := fmt

fmt *ARGS:
cargo +nightly fmt --all {{ ARGS }}

test *ARGS:
cargo test \
--features 'log native libsystemd multi-thread runtime-pattern serde serde_json sval' \
--features 'flexible-string source-location std-stream-captured' \
{{ ARGS }}

clippy *ARGS:
cargo clippy --all-features --tests --examples {{ ARGS }}

check *ARGS:
cargo check --all-features --tests --examples {{ ARGS }}

_doc-default-features *ARGS:
cargo +nightly doc \
--workspace --exclude spdlog-macros --exclude spdlog-internal \
-Z unstable-options -Z rustdoc-scrape-examples {{ ARGS }}

doc *ARGS:
@{{ just }} _doc-default-features --all-features {{ ARGS }}

bench *ARGS:
cargo +nightly bench --features 'multi-thread runtime-pattern serde_json log' {{ ARGS }}

[private]
publish crate-name *ARGS:
cargo clean
cargo package --package {{ crate-name }}
@{{ just }} _publish-confirmed {{ crate-name }} {{ ARGS }}

[confirm("Please check 'target/package' directory, keep going? (y/N)")]
_publish-confirmed crate-name *ARGS:
cargo publish --package {{ crate-name }} {{ ARGS }}
13 changes: 6 additions & 7 deletions spdlog-internal/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[package]
name = "spdlog-internal"
version = "0.2.0"
edition = "2021"
rust-version = "1.66.1"
description = "Internal private common code for crate \"spdlog-rs\""
repository = "https://github.com/SpriteOvO/spdlog-rs"
license = "MIT OR Apache-2.0"
readme = "crates-io.md"
keywords = ["spdlog", "log", "logging"]
categories = ["development-tools::debugging"]
edition.workspace = true
rust-version.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true
categories.workspace = true

[dependencies]
nom = "8.0.0"
Expand Down
File renamed without changes.
13 changes: 6 additions & 7 deletions spdlog-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
[package]
name = "spdlog-macros"
version = "0.3.0"
edition = "2021"
rust-version = "1.66.1"
description = "Macros implementation of crate \"spdlog-rs\""
repository = "https://github.com/SpriteOvO/spdlog-rs"
license = "MIT OR Apache-2.0"
readme = "crates-io.md"
keywords = ["spdlog", "log", "logging"]
categories = ["development-tools::debugging"]
edition.workspace = true
rust-version.workspace = true
repository.workspace = true
license.workspace = true
keywords.workspace = true
categories.workspace = true

[lib]
proc-macro = true
Expand Down
File renamed without changes.
Loading
Loading