Repository navigation
Conversation
`Logger` previously owned its `Vec<Dispatch>` and `Box<dyn ErrorSink>` directly without implementing `Clone` or `Default`, forcing callers and bridges such as `LogBridge` to wrap `Logger` in an external `Arc<Logger>` (or double-`Arc` `LogBridge` itself) whenever sharing a channel across threads or retaining a shutdown `flush()` handle, and preventing libraries from defaulting an optional logger to a `const` zero-allocation value. Represent `Logger` in `logforth-core` as a pointer-sized `Option<Arc<LoggerState>>` (`Clone + Default`) with a zero-allocation `const fn Logger::noop()` (also returned when building an empty `LoggerBuilder`). Simplify `LogBridge` in `logforth-bridge-log` to store `Logger` directly (`Clone`, `const fn LogBridge::new(Logger)`) rather than `Arc<Logger>`, and move `Logger` behavioral tests into `core/tests/logger_test.rs`. Signed-off-by: tison <wander4096@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Make
Loggera lightweight pointer-sizedClonehandle over a shared immutable pipeline with a zero-allocationconst fn Logger::noop(), and remove the redundant outerArc<Logger>wrapper inLogBridge.CloneLoggerhandle andconst fn Logger::noop()(logforth-core): BackLoggerwithOption<Arc<LoggerState>>(8B), implementCloneandDefault, and normalize bothLogger::noop()and emptyLoggerBuilder::build()toNonewith zero heap allocations.Loggerownership inLogBridge(logforth-bridge-log,logforth): StoreLoggerdirectly insideLogBridge(#[derive(Clone)],pub const fn new(logger: Logger)) instead ofArc<Logger>, eliminating double reference-counting when retaining aLoggerhandle alongside globalloginstallation.Loggercontract tests (logforth-core): MoveLoggererror-routing tests out ofcore/src/logger/log_impl.rsintocore/tests/logger_test.rsand add coverage for pointer-size/trait bounds,noop/Default/ empty builder behavior, and cross-thread sharedClonehandles.Breaking Changes
LogBridge::newinlogforth-bridge-lognow acceptsLoggerby value instead ofimpl Into<Arc<Logger>>; passlogger.clone()directly when retaining another handle.