Skip to content

Releases: slog-rs/slog

Fix private field breaking `#` operator in macros

11 Oct 09:44
e694b83

Choose a tag to compare

Fixes issue #364

Release Notes

Fixed

  • Fix use of # operator in macros due to private field (issue #364)
  • ci: Check the tests pass with -Zminimal-versions

Move back to erased_serde v0.3

09 Oct 18:50
a26eb6e

Choose a tag to compare

The upgrade from erased_serde v0.3 to v0.4 in v2.8.0 was a breaking change, as it affected the public API. In the future, we may find a way to upgrade in a backwards-compatible manner. This should not affect normal users of the API but could break drains supporting nested-values.

I (@Techcable) apologize for this breakage and have yanked the 2.8.0 release due to this issue. I will try to setup cargo-semver-checks in the CI to avoid this in the future.

Fixed

  • Restore compatibility with erased-serde version 0.3.
    • Compatibility with erased-serde version 0.4 may be provided again in a
      future version, but will be done so in a backwards compatible way.
    • Thanks to @demurgos for recognizing and fixing this in PR #359
  • Ensure compatibility with -Zminimal-versions flag by specifying minimal dependency versions (fixes #357)

Enable nested-values feature by default

05 Oct 08:31
ec46dcc

Choose a tag to compare

This is the biggest slog release since v2.0! It contains many smaller fixes and improvements to slog that have been accumulated across 5 years and 127 commits.

The nested-values feature was already present in slog, and allows logging serde::Serialize types in addition to primitives. Previously, the nested-values feature had to be enabled not just in slog but also in each drain crate (slog_json, slog_term, slog_async, etc). Enabling this feature by default makes the crate easier to use and avoids several papercts. It should have no runtime overhead if not used and low compile-time overhead thanks to the new serde_core crate.

Another major feature is Logger::flush, which explicitly flushes buffered log messages. The next major release of slog_json, slog_async, etc., will also include support for this feature, in addition to enabling nested-values by default.

Changelog

The following has been copied from CHANGELOG.md

Highlights

  • Enables the nested-values feature by default.
    The next major release of slog_json, slog_term, etc should also enable this feature by default.
  • Added Logger::flush and Drain::flush methods.
  • Improved support for logging errors
    • Have # log specifier transparently support & references to error
    • Implement slog::Value for Box<dyn std::error::Error> and anyhow::Error
  • Define a prelude module for common imports
  • Upgraded to Rust 2018 and require Rust 1.61
    • Deprecate the old slog_log! macros in favor of slog::log!
  • Many internal improvements & bug fixes

Changed

  • Enables the nested-values feature by default.
  • Updated to Rust 2018
  • Bump MSRV to 1.61
    • This is already required for erased-serde, syn, serde_core, and many other important crates in the rust ecosystem.
  • Update erased-serde from v0.3 to v0.4
  • Depend on serde_core rather than serde to reduce compile times.

Added

  • Added a Logger::flush and Drain::flush methods
    • Since this is a new method, not all drains implement it.
      Calling it on an unsupported drain will give an error
  • Define a prelude module for common imports.
    Replace use slog::{Serde, Logger, info, debug, trace} with use slog::prelude::*
  • Optionally implement Drain for parking_lot::Mutex.
    This is noticeably faster than std::sync::Mutex, is smaller, and avoids poisoning.
    • This feature has a separate name per version to allow supporting multiple versions of parking_lot at once. The current version (v0.12) has feature name parking_lot_0_12
  • Implement slog::Value for dyn std::error::Error and Box<dyn std::error:Error (along with the Send/Sync versions).
  • Optionally implement slog::Value for anyhow::Error (requires anyhow feature)
  • Add ErrorRef wrapper to enable logging error references (PR #327)
    • The # error formatter in macros was updated to automatically select ErrorValue or ErrorRef (PR #328)
  • Add emit_bytes method (PR #290)
    • Control formatting using BytesKind enum
  • Implement Value for std::borrow::Cow

Deprecated

  • Deprecate old prefixed macros like slog_log.
    Rust 2018 macro paths like slog::log! make these unnecessary.

Fixed

  • Fix logging of references to errors (resolved by introduction of ErrorRef in PR #327)
  • Take advantage of the fact that in 1.81 std::error::Error has been moved to core.
    On this rust version, slog now supports the error trait without requiring std.
  • Add #[must_use] to most public types, including slog::Logger, slog::OwnedKV, and slog::FnValue.
  • Give a descriptive error when the nested-values feature is unsupported.
  • Alias the slog::Never type to std::convert::Infallible, fixing issue #209.
  • doc: Fix typo in slog::Value docs (issue #335)
  • doc: Fix "lazy continuation" in slog::Logger doc
  • Fix some internal warnings
    • Example: Avoid the new #[warn(unexpected_cfgs)] lint.
    • The crate almost passes clippy::pedantic now, except for a few very verbose lints like clippy::must-use-candidate
    • None of these changes should affect user crates
  • Stop requiring the serde_derive crate to implement the nested-values feature.
    We depend on the new serde_core instead of even requiring serde.
  • The nested-values feature no longer requires serde/std (was a mistake).
  • Always support 128-bit integers, even on the wasm32-unknown-emscripten target.
  • Fix support for feature="nothreads"
    • Internal refactoring to make different feature combos much easier (PR #301)
  • Switch from Travis CI to Github Actions (fixes #294)
    • rustfmt --check now run by default
    • Require clippy to succeed without warnings
    • Require all feature combinations to pass tests.
      • Make exception for nested-values feature on MSRV (1.49),
        because erased-serde dependency requires edition="2021" (needs 1.56)
  • Fix # format when not used as a last argument.
  • Fix duplicate AsRef<str> implementations when using dynamic-keys feature.
  • Fix incorrect 'long' name for slog::Level::Warning (fixes issue #282)