From e44b8a783a68ebc0895963007e3c907672cb73f8 Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 5 Oct 2025 02:11:49 -0700 Subject: [PATCH 1/9] Remove #[cfg(feature = "cargo-clippy")] This has been deprecated in favor of cfg(clippy) and namespaced lints. --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index e329ecf..18d9361 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -193,7 +193,7 @@ where } /// Build custom `Json` `Drain` - #[cfg_attr(feature = "cargo-clippy", allow(clippy::new_ret_no_self))] + #[allow(clippy::new_ret_no_self)] pub fn new(io: W) -> JsonBuilder { JsonBuilder::new(io) } From db38852ad3291fd97b2ac391bd82492e469a80d9 Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 5 Oct 2025 02:13:02 -0700 Subject: [PATCH 2/9] Unconditionally support 128-bit integers Always supported on modern rust & avoids a deprecation warning in slog v2.8. See slog-rs/slog@48e46512418bb9ae55b1daf842edbe10daf181c4 for details. This change has no affect on behavior and does not fix a bug, so does not need to be noted in the changelog. --- src/lib.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 18d9361..f78935c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -// {{{ Crate docs +//! {{{ Crate docs //! JSON `Drain` for `slog-rs` //! //! ``` @@ -23,7 +23,6 @@ extern crate slog; use serde::ser::SerializeMap; -use serde::serde_if_integer128; use slog::Key; use slog::Record; use slog::{FnValue, PushFnValue}; @@ -132,13 +131,11 @@ where fn emit_f64(&mut self, key: Key, val: f64) -> slog::Result { impl_m!(self, key, &val) } - serde_if_integer128! { - fn emit_u128(&mut self, key: Key, val: u128) -> slog::Result { - impl_m!(self, key, &val) - } - fn emit_i128(&mut self, key: Key, val: i128) -> slog::Result { - impl_m!(self, key, &val) - } + fn emit_u128(&mut self, key: Key, val: u128) -> slog::Result { + impl_m!(self, key, &val) + } + fn emit_i128(&mut self, key: Key, val: i128) -> slog::Result { + impl_m!(self, key, &val) } fn emit_str(&mut self, key: Key, val: &str) -> slog::Result { impl_m!(self, key, &val) From 5a7e66cdc87d7fcc1dcd9aecda0456b969787347 Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 5 Oct 2025 02:01:40 -0700 Subject: [PATCH 3/9] ci: Run `typos` for spellchecking Copied from slog-rs/slog --- .github/workflows/spellcheck.yml | 23 +++++++++++++++++++++++ .typos.toml | 17 +++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 .github/workflows/spellcheck.yml create mode 100644 .typos.toml diff --git a/.github/workflows/spellcheck.yml b/.github/workflows/spellcheck.yml new file mode 100644 index 0000000..d713623 --- /dev/null +++ b/.github/workflows/spellcheck.yml @@ -0,0 +1,23 @@ +# Checks spelling with typos +# This has very few false positives, only checking for known misspellings (similar to codespell). +# This action is based on https://github.com/crate-ci/typos/blob/master/docs/github-action.md +name: Check Spelling +on: [push, pull_request] + +env: + CLICOLOR: 1 + +permissions: + contents: read + +jobs: + typos: + # Only run on PRs if the source branch is on someone else's repo + if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} + + name: Check spelling with typos + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run typos (pinned version) + uses: crate-ci/typos@v1.35.1 diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 0000000..428fd06 --- /dev/null +++ b/.typos.toml @@ -0,0 +1,17 @@ +[default] +extend-ignore-re = [ + # support spellchecker directives (ideally this would be builtin) + "(?Rm)^.*(#|//)\\s*spellchecker:ignore$", + "(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on", +] + +[files] +ignore-hidden = false +extend-exclude = [ + ".git", # needed because we set 'ignore-hidden' +] + +[default.extend-identifiers] +# the 'short' identifier for error +erro = "erro" +ERRO = "ERRO" From 81e3e03dc015ba96b862c5973e2c06255a340453 Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 5 Oct 2025 02:03:51 -0700 Subject: [PATCH 4/9] ci: Upgrade workflows for 2025 Based off ones in the slog-rs/slog main repo. --- .github/workflows/clippy.yml | 31 +++++++++------ .github/workflows/rustfmt.yml | 11 +---- .github/workflows/test.yml | 75 ++++++++++++++++++++++++++++------- 3 files changed, 81 insertions(+), 36 deletions(-) diff --git a/.github/workflows/clippy.yml b/.github/workflows/clippy.yml index 4783317..203861d 100644 --- a/.github/workflows/clippy.yml +++ b/.github/workflows/clippy.yml @@ -1,8 +1,3 @@ -# This is the clippy workflow, seperate from the main 'Rust' workflow -# -# This will fail if clippy fails (if we encounter any of its "correctness" lints) -# -# Clippy warnings won't fail the build. They may or may not turn into Github warnings. on: [push, pull_request] name: Clippy @@ -18,19 +13,31 @@ jobs: clippy: # Only run on PRs if the source branch is on someone else's repo if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} + runs-on: ubuntu-latest strategy: + fail-fast: false matrix: rust: + # in hardcoded versions, warnings will fail the build + - 1.90 + # in auto-updated versions, warnings will not fail the build - stable + - nightly + steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: - profile: minimal toolchain: ${{ matrix.rust }} - override: true - components: clippy - - shell: bash + components: clippy + - uses: Swatinem/rust-cache@v2 + if: ${{ matrix.rust != 'nightly' }} + - name: Clippy run: | - cargo clippy + cargo clippy --all --all-targets --verbose --all-features -- -D warnings + # When using hardcoded/pinned versions, warnings are forbidden. + # + # On automatically updated versions of rust (both stable & nightly) we allow clippy to fail. + # This is because automatic updates can introduce new lints or change existing lints. + continue-on-error: ${{ !contains(matrix.rust, '1.') }} diff --git a/.github/workflows/rustfmt.yml b/.github/workflows/rustfmt.yml index 72659f5..3971261 100644 --- a/.github/workflows/rustfmt.yml +++ b/.github/workflows/rustfmt.yml @@ -14,17 +14,10 @@ jobs: # Only run on PRs if the source branch is on someone else's repo if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} runs-on: ubuntu-latest - strategy: - matrix: - rust: - - stable steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable with: - profile: minimal - toolchain: ${{ matrix.rust }} - override: true components: rustfmt - shell: bash run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bf87745..d34ede7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,8 +1,6 @@ # We use `actions-rs` for most of our actions # -# This file is for the main tests. clippy & rustfmt are seperate workflows -# -# It is mostly copied from slog-rs/slog +# This file is for the main tests. clippy & rustfmt are separate workflows on: [push, pull_request] name: Cargo Test @@ -28,24 +26,71 @@ jobs: strategy: fail-fast: false # Even if one job fails we still want to see the other ones matrix: - # 1.53 is MSRV. Keep in sync with Cargo.toml - rust: [1.53, stable, nightly] - # NOTE: Features to test must be specified manually. They are applied to all versions seperately. + rust: + # Minimum Supported Rust Version + # + # This is hardcoded and needs to be in sync with Cargo.toml and the README + - 1.53 + + # Intermediate Releases (between MSRV and latest stable) + # Be careful not to add these needlessly; they hold up CI + # + + # The most recent version of stable rust (automatically updated) + - stable + - nightly + # NOTE: Features to test must be specified manually. They are applied to all versions separately. # - # This has the advantage of being more flexibile and thorough - # This has the disadvantage of being more vebrose + # This has the advantage of being more flexible and thorough + # This has the disadvantage of being more verbose # - # Specific feature combos can be overriden per-version with 'include' and 'exclude' - features: ["", "nested-values", "dynamic-keys", "nested-values dynamic-keys"] + # Specific feature combos can be overridden per-version with 'include' and 'ecclude' + features: + - "" + - "nested-values" + - "dynamic-keys" + - "nested-values dynamic-keys" steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master with: toolchain: ${{ matrix.rust }} - override: true - # NOTE: We only run `cargo test`. No need for a seperate `cargo check` + - uses: Swatinem/rust-cache@v2 + if: ${{ matrix.rust != 'nightly' }} # ineffective due to version key + - name: Check + run: | + cargo check --all-targets --verbose --no-default-features --features "${{ matrix.features }}" + # A failing `cargo check` always fails the build + continue-on-error: false - name: Test + # NOTE: Running --all-targets does not include doc tests run: | - cargo test --verbose --features "${{ matrix.features }}" + cargo test --all --verbose --no-default-features --features "${{ matrix.features }}" + # We require tests to succeed on all the feature combinations. + # + # However, we can grant special exceptions for the Minimum Supported Rust Version + # if there is a really good reason (like a dependency that requires a newer version). + continue-on-error: false + - name: rustdoc + # Restrict to working on nightly/stable (old versions might have undefined types) + if: ${{ matrix.rust == 'nightly' || matrix.rust == 'stable' }} + env: + RUSTDOCFLAGS: -Dwarnings + run: | + cargo doc --no-deps --all --verbose --no-default-features --features "${{ matrix.features }}" + # Runs the same build that docs.rs does. See https://github.com/dtolnay/cargo-docs-rs + docsrs: + # Only run on PRs if the source branch is on someone else's repo + if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }} + + name: docs.rs + runs-on: ubuntu-latest + env: + RUSTDOCFLAGS: -Dwarnings + steps: + - uses: actions/checkout@v5 + - uses: dtolnay/rust-toolchain@nightly + - uses: dtolnay/install@cargo-docs-rs + - run: cargo docs-rs From 4d3ea90ac64a05f3ed4b1d060ffd998edf693b6f Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 5 Oct 2025 02:58:53 -0700 Subject: [PATCH 5/9] ci: Cache on failure Helpful for old rust versions circa 1.61, which use the legacy index. --- .github/workflows/test.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d34ede7..e7df124 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -58,6 +58,14 @@ jobs: toolchain: ${{ matrix.rust }} - uses: Swatinem/rust-cache@v2 if: ${{ matrix.rust != 'nightly' }} # ineffective due to version key + with: + # Helpful for Rust versions that use old index + cache-on-failure: true + # Pin a time version with a compatible MSRV + - name: Pin time version + if: ${{ matrix.rust != 'nightly' && matrix.rust != 'stable' }} + run: | + cargo update --package time --precise 0.3.16 - name: Check run: | cargo check --all-targets --verbose --no-default-features --features "${{ matrix.features }}" From 50fe2caeb12e55eb0bc418fc4846e5c0f688c7ed Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 5 Oct 2025 01:51:13 -0700 Subject: [PATCH 6/9] Upgrade to slog v2.8 Implement Drain::flush and enable the `nested-values` feature by default. --- .github/workflows/test.yml | 2 +- CHANGELOG.md | 9 +++++++++ Cargo.toml | 15 +++++++-------- src/lib.rs | 5 +++++ 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e7df124..6f9e7b5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -30,7 +30,7 @@ jobs: # Minimum Supported Rust Version # # This is hardcoded and needs to be in sync with Cargo.toml and the README - - 1.53 + - 1.61 # Intermediate Releases (between MSRV and latest stable) # Be careful not to add these needlessly; they hold up CI diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d20119..f37884a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +### Changed +* Upgrade to [slog v2.8.0]. + * Enable `nested-values` feature by default + * Increase MSRV to 1.61 (same as slog) + +### Added +* Implement `Drain::flush` (new in [slog v2.8.0]) + +[slog v2.8.0]: https://github.com/slog-rs/slog/releases/v2.8.0 ## 2.6.0 - 2022-02-20 ### Changed diff --git a/Cargo.toml b/Cargo.toml index bef3910..9e0f503 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,24 +15,23 @@ readme = "README.md" # Please do not bump this unnecessarily. # Changing this should bump the minor version for semver (2.x for semver). # -# The first version of Cargo that supports this field was in Rust 1.56.0. -# In older releases, the field will be ignored, and Cargo will display a warning. -rust-version = "1.53" +# This currently matches the MSRV of slog +rust-version = "1.61" [features] -nested-values = ["erased-serde", "slog/nested-values"] +default = ["nested-values"] +nested-values = ["dep:erased-serde", "slog/nested-values"] dynamic-keys = ["slog/dynamic-keys"] -default = [] [dependencies] -slog = { version = "2.1.1" } +slog = "2.8" serde_json = "1" serde = "1" -erased-serde = {version = "0.3", optional = true } +erased-serde = { version = "0.4", optional = true } time = { version = "0.3.6", features = ["formatting"] } [dev-dependencies] slog-async = "2" [package.metadata.docs.rs] -features = ["nested-values", "dynamic-keys"] +features = ["dynamic-keys"] diff --git a/src/lib.rs b/src/lib.rs index f78935c..b287788 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -251,6 +251,11 @@ where } Ok(()) } + + fn flush(&self) -> Result<(), slog::FlushError> { + let mut io = self.io.borrow_mut(); + io.flush().map_err(slog::FlushError::from) + } } // }}} From 36e20026c65c8338d95c4cbc120552a436dc6da0 Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 5 Oct 2025 02:43:25 -0700 Subject: [PATCH 7/9] ci: Pin dependency versions for 1.61 MSRV Similar to something we do in slog-term, but with way more pinned dependencies. It would be nice to do this automatically. --- .github/workflows/test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6f9e7b5..5c01ad8 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -62,10 +62,13 @@ jobs: # Helpful for Rust versions that use old index cache-on-failure: true # Pin a time version with a compatible MSRV - - name: Pin time version + - name: Pin dependency versions for MSRV if: ${{ matrix.rust != 'nightly' && matrix.rust != 'stable' }} run: | cargo update --package time --precise 0.3.16 + cargo update --package thread_local --precise 1.1.8 + cargo update --package libc --precise 0.2.163 + cargo update --package once_cell --precise 1.20.2 - name: Check run: | cargo check --all-targets --verbose --no-default-features --features "${{ matrix.features }}" From 5704d0d55d84295aaf434bbed3983e479d383bdc Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 5 Oct 2025 02:38:25 -0700 Subject: [PATCH 8/9] Depend on serde_core rather than serde Use cargo package renaming to avoid changing any code. --- CHANGELOG.md | 1 + Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f37884a..1e429b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * Upgrade to [slog v2.8.0]. * Enable `nested-values` feature by default * Increase MSRV to 1.61 (same as slog) +* Switch from `serde` to `serde_core`. Should reduce compile times. ### Added * Implement `Drain::flush` (new in [slog v2.8.0]) diff --git a/Cargo.toml b/Cargo.toml index 9e0f503..371bbbd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,7 @@ dynamic-keys = ["slog/dynamic-keys"] [dependencies] slog = "2.8" serde_json = "1" -serde = "1" +serde = { package = "serde_core", version = "1" } erased-serde = { version = "0.4", optional = true } time = { version = "0.3.6", features = ["formatting"] } From 22560c3713bb2792e05271715b53bbe9100182c5 Mon Sep 17 00:00:00 2001 From: Techcable Date: Sun, 5 Oct 2025 02:40:45 -0700 Subject: [PATCH 9/9] Bump version to v2.7.0 Date in changelog will likely be incorrect due to merge delay (I cannot commit to master). --- CHANGELOG.md | 3 +++ Cargo.toml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e429b6..55784a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] + +## 2.7.0 - 2025-10-05 + ### Changed * Upgrade to [slog v2.8.0]. * Enable `nested-values` feature by default diff --git a/Cargo.toml b/Cargo.toml index 371bbbd..80a8bc7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "slog-json" -version = "2.6.1" +version = "2.7.0" edition = "2018" authors = ["Dawid Ciężarkiewicz "] description = "JSON drain for slog-rs"