Stderr

Struct Stderr 

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

An appender that writes log records to standard error.

§Examples

use logforth_core::append::Stderr;

let stderr_appender = Stderr::default();

Implementations§

Source§

impl Stderr

Source

pub fn with_layout(self, layout: impl Into<Box<dyn Layout>>) -> Stderr

Set the layout for the Stderr appender.

Default to PlainTextLayout.

§Examples
use logforth_core::append::Stderr;
use logforth_core::layout::PlainTextLayout;

let stderr_appender = Stderr::default().with_layout(PlainTextLayout::default());
Examples found in repository?
examples/task_local.rs (line 28)
23async fn main() {
24    logforth::starter_log::builder()
25        .dispatch(|d| {
26            d.filter(LevelFilter::All)
27                .diagnostic(TaskLocalDiagnostic::default())
28                .append(logforth::append::Stderr::default().with_layout(TextLayout::default()))
29        })
30        .apply();
31
32    async {
33        async {
34            log::error!("Hello error!");
35            log::warn!("Hello warn!");
36            log::info!("Hello info!");
37        }
38        .with_task_local_context([("k3".to_string(), "v3".to_string())])
39        .await;
40        log::debug!("Hello debug!");
41        log::trace!("Hello trace!");
42    }
43    .with_task_local_context([("k1".to_string(), "v1".to_string())])
44    .with_task_local_context([("k2".to_string(), "v2".to_string())])
45    .await;
46}

Trait Implementations§

Source§

impl Append for Stderr

Source§

fn append( &self, record: &Record<'_>, diags: &[Box<dyn Diagnostic>], ) -> Result<(), Error>

Dispatch a log record to the append target.
Source§

fn flush(&self) -> Result<(), Error>

Flush any buffered records.
Source§

fn exit(&self) -> Result<(), Error>

Perform any cleanup work before the program exits. Read more
Source§

impl Debug for Stderr

Source§

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

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

impl Default for Stderr

Source§

fn default() -> Stderr

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

Auto Trait Implementations§

§

impl Freeze for Stderr

§

impl !RefUnwindSafe for Stderr

§

impl Send for Stderr

§

impl Sync for Stderr

§

impl Unpin for Stderr

§

impl !UnwindSafe for Stderr

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> FutureExt for T

Source§

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

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

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext 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 = 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V