Skip to main content

ContainerLog

Struct ContainerLog 

Source
pub(crate) struct ContainerLog {
    drivers: Vec<Driver>,
    lines: LineBuffer,
    buffers_lines: bool,
}
Expand description

The log drivers of a container.

Fields§

§drivers: Vec<Driver>§lines: LineBuffer

Collects whole lines for the journald drivers, the only ones which take them.

§buffers_lines: bool

Whether any driver takes whole lines.

Implementations§

Source§

impl ContainerLog

Source

pub(crate) fn new() -> Arc<Mutex<ContainerLog>> ⓘ

Create a new default SharedContainerLog.

Source

pub(crate) fn has_drivers(&self) -> bool

Check if this logger has any drivers configured.

Source

pub(crate) fn from_request( id: &str, reader: Reader<'_, Owned>, ) -> Result<Arc<Mutex<ContainerLog>>>

Create a new SharedContainerLog for the container id from the requested drivers.

Source

fn path<'a>(driver: &Reader<'a>) -> Result<&'a Path>

The path of a requested driver, which has to be absolute.

Source

fn max_size(driver: &Reader<'_>) -> Option<usize>

The maximum log size of a requested driver, zero means unlimited.

Source

pub(crate) async fn init(&mut self) -> Result<()>

Asynchronously initialize all loggers.

Source

pub(crate) async fn reopen(&mut self) -> Result<()>

Reopen the container logs. All drivers get reopened even if one fails, the first error is returned.

Source

pub(crate) async fn write(&mut self, pipe: Pipe, bytes: &[u8]) -> Result<()>

Write the contents of the provided bytes into all loggers. All of them get the chunk even if one fails, the first error is returned.

Source

pub(crate) fn has_pending(&self, pipe: Pipe) -> bool

Whether a line of the pipe waits for its ending.

Source

pub(crate) async fn flush(&mut self, pipe: Pipe) -> Result<()>

Write the line of the pipe which waits for its ending as a partial one, because the output paused.

Source

pub(crate) async fn finish(&mut self, pipe: Pipe) -> Result<()>

The output of the pipe ended, write the line which still waits for its ending.

Source

pub(crate) async fn sync(log: &Arc<Mutex<ContainerLog>>) -> Result<()>

Sync the data of the log files to disk, like conmon does once the container exited. The log is not locked while the files sync, they get synced even if one fails, the first error is returned. A file which cannot be synced, like a device, has nothing to sync. Only a few logs sync at a time, syncs which hang on a stuck disk keep a quarter of the threads of the blocking pool at most, see Server::MAX_BLOCKING_THREADS. Tests, which share the static, do not wait for each other.

Source

async fn write_lines(&mut self, pipe: Pipe, lines: &[Line<'_>]) -> Result<()>

Hand the lines to every driver which takes them. All of them get the lines even if one fails, the first error is returned.

Trait Implementations§

Source§

impl Debug for ContainerLog

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ContainerLog

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

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

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

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.

§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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