Struct Output

Source
pub struct Output { /* private fields */ }
Expand description

Represents the output buffer for log data before it’s sent to S3. Manages buffering, naming, and partitioning of log files.

Implementations§

Source§

impl Output

Source

pub fn new(prefix: &str, postfix: &str) -> Self

Creates a new Output instance with the specified prefix and postfix.

§Arguments
  • prefix - The prefix for log file names
  • postfix - The postfix/extension for log file names
§Returns

A new Output instance with initialized buffer and metadata

Source

pub fn bump_part(&mut self)

Increments the part number and updates the file name. Called when the current log file becomes too large and needs to be split.

Source

pub fn gen_name(prefix: &str, part: u64, postfix: &str, nonce: &str) -> String

Generates a log file name based on the current date, part number, and configuration.

§Arguments
  • prefix - The file name prefix
  • part - The part number for file splitting
  • postfix - The file extension/postfix
  • nonce - A unique identifier for this logging session
§Returns

A formatted file name in the pattern: YYYY-MM-DD/part/prefix-nonce.postfix

Source

pub async fn buffer_len(&self) -> u64

Returns the number of log entries currently in the buffer.

Source

pub async fn flush_buffer(&self) -> String

Flushes the buffer and returns all buffered log entries as a single string. Clears the buffer and resets the size counter after flushing.

§Returns

A newline-delimited string containing all buffered log entries

Source

pub async fn append_to_buffer(&self, value: String)

Appends a log entry to the buffer and updates the size counter.

§Arguments
  • value - The log entry to append to the buffer
Source

pub fn name(&self) -> String

Returns the current log file name.

Source

pub fn size_in_bytes(&self) -> u64

Returns the current buffer size in bytes.

Source

pub fn part(&self) -> u64

Returns the current part number.

Source

pub fn update_size_in_bytes(&self, size_in_bytes: u64)

Updates the buffer size counter.

§Arguments
  • size_in_bytes - The new buffer size in bytes
Source

pub fn update_name(&mut self, name: &str)

Updates the current log file name.

§Arguments
  • name - The new file name

Auto Trait Implementations§

§

impl Freeze for Output

§

impl !RefUnwindSafe for Output

§

impl Send for Output

§

impl Sync for Output

§

impl Unpin for Output

§

impl !UnwindSafe for Output

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,