Stdout

Struct Stdout 

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

An appender that writes log records to standard output.

§Examples

use logforth_core::append::Stdout;

let stdout_appender = Stdout::default();

Implementations§

Source§

impl Stdout

Source

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

Set the layout for the Stdout appender.

Default to PlainTextLayout.

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

let stdout_appender = Stdout::default().with_layout(PlainTextLayout::default());
Examples found in repository?
examples/json_stdout.rs (line 22)
20fn main() {
21    logforth::starter_log::builder()
22        .dispatch(|d| d.append(append::Stdout::default().with_layout(JsonLayout::default())))
23        .apply();
24
25    log::info!("This is an info message.");
26    log::debug!("This debug message will not be printed by default.");
27}
More examples
Hide additional examples
examples/custom_layout_filter.rs (line 54)
50fn main() {
51    logforth::starter_log::builder()
52        .dispatch(|d| {
53            d.filter(CustomFilter)
54                .append(append::Stdout::default().with_layout(CustomLayout))
55        })
56        .apply();
57
58    log::error!("Hello error!");
59    log::warn!("Hello warn!");
60    log::info!("Hello info!");
61    log::debug!("Hello debug!");
62    log::trace!("Hello trace!");
63}
examples/google_cloud_logging.rs (lines 45-49)
40fn main() {
41    logforth::starter_log::builder()
42        .dispatch(|d| {
43            d.diagnostic(diagnostic::FastraceDiagnostic::default())
44                .append(
45                    append::Stdout::default().with_layout(
46                        GoogleCloudLoggingLayout::default()
47                            .trace_project_id("project-id")
48                            .label_keys(["label1"]),
49                    ),
50                )
51        })
52        .apply();
53
54    fastrace::set_reporter(ConsoleReporter, Config::default());
55
56    {
57        let root = Span::root("root", SpanContext::new(TraceId::random(), SpanId(0)));
58        let _g = root.set_local_parent();
59
60        let structured_value = MyStructuredValue {
61            a: 1,
62            b: NestedStructuredValue {
63                c: "Hello".into(),
64                d: true,
65            },
66        };
67
68        log::info!(
69            label1 = "this is a label value",
70            notLabel:serde = structured_value;
71            "Hello label value!",
72        );
73    }
74}

Trait Implementations§

Source§

impl Append for Stdout

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 Stdout

Source§

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

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

impl Default for Stdout

Source§

fn default() -> Stdout

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

Auto Trait Implementations§

§

impl Freeze for Stdout

§

impl !RefUnwindSafe for Stdout

§

impl Send for Stdout

§

impl Sync for Stdout

§

impl Unpin for Stdout

§

impl !UnwindSafe for Stdout

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