Releases: SpriteOvO/spdlog-rs
Releases · SpriteOvO/spdlog-rs
v0.5.2
Changelog
- Fix
kvargument in logging macros not accepting references. Values are now constructed usingValueBag::frominstead ofValueBag::capture. (PR #109) - Introduce
AtomicLevelFilterto replaceatomic::Atomic<LevelFilter>, which has undefined behavior. (PR #110) - Flush sinks on program exit with a special method
Sink::flush_on_exit. (PR #102, thanks @tisonkun) - Add a builder for
FullFormatterthat allows configuring the presence of each field. (PRs #108 #114) - Allow
StdStreamSinkto write tostdoutandstderrvia print macros. It is useful if you want the logs to be captured bycargo testandcargo bench. (PR #106, issue #105) - Allow setting up filter for records from
logcrate viaLogCrateProxy::set_filtermethod. (PR #111) - Add a shorthand method
build_arcto all sink builder structs. (PR #107) - Add a public
Level::countmethod. - Deprecate
AsyncPoolSinkBuilder::formattermethod.AsyncPoolSinkdoes not have its own formatter, this method has no effect and was added by accident. - Add
justfileto repository. - Bump MSRV to 1.71.
- Documentation improvements:
- Builder methods documentation now describes their default values.
- Default values for
SinkProp::defaultare now documented. - Update documentation of
StringBuf. - Enable Rustdoc examples scraping on docs.rs.
v0.5.1
v0.5.0
Highlights / New Features
- Structured logging supports. (issue #70, PR #77)
- A new named optional parameter
kvis accepted in logging macros for recording with structured key-value pairs.info!("program started", kv: { pid = std::process::id() });
- A new pattern placeholder
{kv}is added to pattern macros for writing out structured key-value pairs.pattern!("{datetime} {^{level}} {payload} {{ {kv} }}{eol}")
- Access key-value pairs in records via a new method
Record::key_values. - The named optional parameters in logging macros are allowed to be placed in arbitrary order.
info!(logger: my_app, kv: { a = 1 }, "1 + a = {}", 2); // OK info!(logger: my_app, "1 + a = {}", 2, kv: { a = 1 }); // OK info!("1 + a = {}", 2, logger: my_app, kv: { a = 1 }); // OK info!(kv: { a = 1 }, "1 + a = {}", 2, logger: my_app); // OK info!(logger: my_app, "1 + a = {}", kv: { a = 1 }, 2); // Error
- MSRV (minimum supported Rust version) is bumped to v1.66.1.
- A new sink
AndroidSinkallows writing out logs to Android NDK log framework. (issue #96, PR #97) JournaldSinkpasses an additionalTIDfield to journald.- Allow configuring the capacity of
BufWriterfor file sinks via new methods{FileSinkBuilder,RotatingFileSinkBuilder}::capacity. - Allow passing a runtime level value to
log!macro. - Use a semantically non-zero type for
ThreadPoolBuilder,InvalidArgumentError::ThreadPoolCapacityis marked as deprecated. (thanks @tisonkun, #94). - Some implicit dependencies are no longer exposed as public enabled feature gates.
- Replace spin locks with std locks (#92).
- Add an error variant
Downstream(Box<dyn std::error::Error>for downstream crates. - Mark
swap_default_loggerfunction as#[must_use]. - Fix
runtime_pattern!macro requiring explicitspdlog-internaldependency. - Benchmarking code is excluded from crates.io releases to reduce package size.
- Fix typo in documentation. (thanks @felixonmars, #100)
Migrating from v0.4
v0.5 made some breaking changes for better interaction of downstream crates with spdlog-rs.
- Methods
Sink::{level_filter,set_level_filter,set_formatter,set_error_handler}are moved to a new traitSinkPropAccess, and traitSinkinherits it. (issue #71, PR #93)
If you are implementing your own sink, you may want to define a field with typeSinkPropwithin your sink and then implement the new traitGetSinkPropfor your sink. This will make your sink automatically get traitSinkPropAccessimplemented. - For methods
{set_,}formatterinLoggerand sink builders, anInto<Foramtter>is now accepted instead of aBox<dyn Formatter>. ErrorHandleris no longer used withOption, to represent an emptyErrorHandler, useErrorHandler::default(). This allows downstream crates to be able to call the internal default error handler. (#86)ThreadPoolBuilder::capacitynow accepts aNonZeroUsizeinstead of ausize.
v0.4.3
v0.4.2
v0.4.1
Changes
- Add shortcut methods
StdStreamSinkBuilder::{stdout,stderr}. - Implement
DebugforLogger(#81, thanks @Nicholas-Clavette). - Support builds for FreeBSD and Illumos (#83).
- Emit an error in macro
runtime_patternif crate feature is not enabled.
v0.4.0
Highlights / New Features
- Performance is improved by 15% (see Benchmarks), and the performance of
PatternFormatterhas been significantly improved. - Most of the documentation and examples have been rewritten, they should now be more friendly to people new to this crate.
- Support constructing
PatternFormatterfrom a runtime string via the new macroruntime_pattern!. (PR #45) - New formatter
JsonFormatterserializes log into a single line of JSON object. (PR #69, thank @NotEvenANeko) - New sink
DedupSinkfor skipping consecutive repeated logs. RotatingFileSinknow has a new rotation policyPeriodrotates after a given period. (PR #74, thank @lioriz)- New methods
on_thread_spawnandon_thread_finishforThreadPoolBuilderallows to set callbacks for thread spawn and finish. (PR #54, thank @fpervaiz) - New method
Record{,Owned}::tidto get the thread ID when the log was generated.
Improvements / Bug Fixes
- MSRV (minimum supported Rust version) is bumped to v1.60.
- Fixed
AsyncPoolSinkmay lose the last logs and may panic. (PR #66) - Fallback logger name to the target from
logcrate if present. (PR #50, thank @Lancern) - Respect local timezone when rotating files by time point.
- Several internal performance optimizations.
Breaking Changes
Formatter::clone_boxis removed, now it requires all formatters to implementClone. The inheritedDynClonetrait enables it to be cloned object-safely.FmtExtraInfo{,Builder}has been replaced withFormatterContext, andFormatter::formatnow has a&mut FormatterContextargument instead of returningResult<FmtExtraInfo>.- All re-exported
logitems has been moved from modulelog_cratetore_export::log. - Method
LevelFilter::compareis renamed toLevelFilter::test. The old method is still available, but has been marked as#[deprecated]and may be removed in a future release. - Box the
RecordOwnedin structSendToChannelErrorDroppedto avoid moving large structures on the stack. - Implementors of
Sink::logare no longer required to callshould_logto filter logs. Now spdlog-rs will always check first by callingshould_log, and only calllogwhen it returnstrue. PatternContextnow has 2 new lifetimes.