Skip to main content

Config

Struct Config 

Source
pub struct Config {
    pub module_id: String,
    pub logs_dir: PathBuf,
    pub bound: Vec<(String, String)>,
    pub spec: Option<String>,
    pub retention: SegmentRetention,
    pub redactor: Option<Arc<Redactor>>,
    pub clock: Option<Arc<dyn Fn() -> SystemTime + Send + Sync>>,
}
Expand description

Logger configuration for one process.

Fields§

§module_id: String

Stable fleet module identifier: the root of every logger name and the first part of every segment’s file name.

§logs_dir: PathBuf

The directory the segments live in. Fleet callers never assemble this: Config::for_module derives it from the module id through the same resolver every store uses, so a log cannot land beside the wrong data. Public for tests and for the daemon’s own run/logs/ lane, which is not a module data directory.

§bound: Vec<(String, String)>

Fields bound for the whole process and rendered in the bracket on every line, in this order. A harness-hosted plugin binds harness=<name> here: after r2 every lane shares one segment and this is what tells them apart.

§spec: Option<String>

CK_LOG override; None reads the process environment.

§retention: SegmentRetention

Age window and oversize alarm for the segments.

§redactor: Option<Arc<Redactor>>

Optional module redactor, applied after fleet credential redaction.

§clock: Option<Arc<dyn Fn() -> SystemTime + Send + Sync>>

Optional clock override for deterministic callers and tests.

Implementations§

Source§

impl Config

Source

pub fn in_dir(module_id: &str, logs_dir: impl Into<PathBuf>) -> Self

A configuration whose segment directory the caller already resolved: CK_LOG from the environment, fleet default retention, nothing bound. This is the path for a consumer that owns its module data directory through its own pinned store crate and must not pull a second copy of it through this one (see the store-paths feature).

Source

pub fn for_module(module_id: &str) -> Self

The fleet configuration for a supervised module’s own process: segments under <module data dir>/logs/, CK_LOG from the environment (the daemon injects it at spawn), fleet default retention, nothing bound.

Source

pub fn for_plugin(module_id: &str, harness: &str) -> Self

Config::for_module with harness=<harness> bound on every line, for a plugin running inside a harness process.

Source

pub fn from_env() -> Result<Self, InitError>

The configuration a supervised module can build with no arguments, because the daemon already injects everything it needs at spawn: SUBC_MODULE_ID (for launch attestation), CK_LOG, and the retention knobs as CK_LOG_MAX_AGE_DAYS / CK_LOG_ALARM_SEGMENT_MB. This is the zero-argument path the r2 spec requires so that reaching for the crate costs no more than reaching for eprintln!.

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