Skip to main content

Logger

Struct Logger 

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

Writes redacted lines to one data folder’s log. The caller only queues the event; one background thread renders, redacts and writes (file I/O, the lock, rotation and retries never run on the caller’s thread). Dropping the logger writes what is queued before it returns.

Implementations§

Source§

impl Logger

Source

pub fn for_home( env: &Env, home: &SurjectionHome, source: &'static str, ) -> Option<Logger>

The log of home, written as source (cli, app); None when LOG_ENV_VAR turns it off (or the writer thread cannot start).

Source

pub fn with_rotation(self, rotation: Rotation) -> Self

Source

pub fn path(&self) -> PathBuf

The current log file.

Source

pub fn write(&self, event: &str, fields: &[(&str, &dyn Display)])

Queues one line. Nothing is written while the data folder does not exist (a log never creates it); I/O errors are ignored.

Source

pub fn flush(&self)

Waits (up to two seconds) until every line queued so far is written.

Trait Implementations§

Source§

impl Debug for Logger

Source§

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

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

impl Drop for Logger

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !Freeze for Logger

§

impl !RefUnwindSafe for Logger

§

impl !UnwindSafe for Logger

§

impl Forget for Logger

§

impl Move for Logger

§

impl Send for Logger
where RawVecInner: Send, NodeRef<Owned, String, OsString, LeafOrInternal>: Send, BoxRaw<(String, OsString)>: Send, Arc<dyn Clock>: Send, Mutex<Option<Sender<Message>>>: Send, Mutex<Option<JoinHandle<()>>>: Send,

§

impl Sync for Logger
where RawVecInner: Sync, NodeRef<Owned, String, OsString, LeafOrInternal>: Sync, BoxRaw<(String, OsString)>: Sync, Arc<dyn Clock>: Sync, Mutex<Option<Sender<Message>>>: Sync, Mutex<Option<JoinHandle<()>>>: Sync,

§

impl Unpin for Logger
where *const u8 is !null: Unpin, *const LeafNode<String, OsString> is !null: Unpin, Box<(String, OsString)>: Unpin, Arc<dyn Clock>: Unpin, Align4<u32>: Unpin, Align1<u8>: Unpin, *mut Counter<Channel<Message>>: Unpin, *mut Counter<Channel<Message>>: Unpin, *mut Counter<Channel<Message>>: Unpin, Arc<Inner, System>: Unpin, Arc<Packet<'static, ()>>: Unpin,

§

impl UnsafeUnpin for Logger
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, *const LeafNode<String, OsString> is !null: UnsafeUnpin, PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin, PhantomData<Box<(String, OsString)>>: UnsafeUnpin, *const ArcInner<dyn Clock> is !null: UnsafeUnpin, PhantomData<ArcInner<dyn Clock>>: UnsafeUnpin, Align4<u32>: UnsafeUnpin, Align1<u8>: UnsafeUnpin, *mut Counter<Channel<Message>>: UnsafeUnpin, *mut Counter<Channel<Message>>: UnsafeUnpin, *mut Counter<Channel<Message>>: UnsafeUnpin, *const ArcInner<Inner> is !null: UnsafeUnpin, PhantomData<ArcInner<Inner>>: UnsafeUnpin, *const ArcInner<Packet<'static, ()>> is !null: UnsafeUnpin, PhantomData<ArcInner<Packet<'static, ()>>>: UnsafeUnpin,

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> 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 = !

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