Repository navigation
Conversation
Remove `Append::flush` from `logforth_core::Append` so `Append` becomes a single-method record sink trait (`Append::append`), and drop the now-redundant `SdkLoggerProvider` field from `OpentelemetryLog`. Sinks that buffer or batch out-of-band manage draining and teardown through their own dedicated lifecycle handles (`AsyncGuard` for `logforth-append-async` and `SdkLoggerProvider` for `logforth-append-opentelemetry`), eliminating ambiguous trait-level flush hooks. 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.
Note
PR Stack (
#338exploration)Logger::flush, splitAsyncBuilder::buildinto(Async, AsyncGuard), and defaultAppend::flushtoOk(()).Append::flushfromAppendaltogether.Refs #338.
Problem
Across all 10 built-in
Appendimplementations in Logforth, 7 perform zero user-space buffering (Testing,Stderr,Stdoutwith trailing\n,Fileover rawstd::fs::File,Journald,PosixSyslog, andSocketSyslog, whose stream senders already flush per record), 2 delegate to external SDKs that own their own lifecycle handles (fastrace::flush()andSdkLoggerProvider::force_flush()/shutdown()), and onlyAsyncbuffers records internally in Logforth (whose queue lifecycle is now owned byAsyncGuard).Keeping
Append::flushon the core trait leaves an ambiguous second flush path alongside dedicated sink handles (AsyncGuard::flush/DropandSdkLoggerProvider::force_flush/shutdown), while callers holdingBox<dyn Append>orLoggerhave no sink-agnostic flush trigger onceLogger::flushis removed.Solution
Append::flushfromlogforth_core::Append:Appendbecomes a single-method trait (fn append(&self, record: &Record, diags: &dyn Diagnostic) -> Result<(), Error>).Append::flushimplementations: DropAppend::flushfromArc<T>,&'static T,Stdout,SocketSyslog(Dropstill flushes the underlyinglogforth_syslog::Sender),OpentelemetryLog(along with its now-redundantSdkLoggerProviderfield), andAsync(as well asflush_appendsinsidelogforth-append-async).AsyncGuard::flushandAsyncGuardDropdrain:AsyncGuard::flush(&self) -> Result<(), Error>continues to enqueue a synchronous barrier on the worker queue until all preceding records are processed, and droppingAsyncGuarddrains pending records and joins the worker thread.