Struct LogstashFormat

Source
pub struct LogstashFormat<FC = (), SF = DefaultSpanFormat> { /* private fields */ }
Expand description

Display options for the logstash output format

§Example

let logger = tracing_logstash::Layer::default().event_format(
   tracing_logstash::logstash::LogstashFormat::default()
        .with_timestamp(false),
);

Implementations§

Source§

impl<FC, SF> LogstashFormat<FC, SF>

Source

pub fn with_timestamp(self, display_timestamp: bool) -> Self

Source

pub fn with_version(self, display_version: bool) -> Self

Source

pub fn with_logger_name(self, display_logger_name: Option<LoggerName>) -> Self

Source

pub fn with_thread_name(self, display_thread_name: bool) -> Self

Source

pub fn with_level(self, display_level: bool) -> Self

Source

pub fn with_level_value(self, display_level_value: bool) -> Self

Source

pub fn with_span_list( self, display_span_list: Option<DisplayLevelFilter>, ) -> Self

Source

pub fn with_stack_trace( self, display_stack_trace: Option<(DisplayLevelFilter, DisplayLevelFilter)>, ) -> Self

Source

pub fn with_span_fields(self, span_fields: Vec<FieldSpec>) -> Self

Source

pub fn with_field_contributor<FC2>( self, field_contributor: FC2, ) -> LogstashFormat<FC2, SF>

Add dynamically generated fields to every event

§Example
struct DynamicFields;
impl LogFieldContributor for DynamicFields {
    fn add_fields<F>(&self, serializer: &mut F)
    where
        F: LogFieldReceiver,
    {
        serializer.add_field("string_field", "fnord");
        serializer.add_field("number_field", &42);
   }
}

let logger = tracing_logstash::Layer::default().event_format(
    tracing_logstash::logstash::LogstashFormat::default()
        .with_field_contributor(DynamicFields),
);
Source

pub fn with_constants(self, constants: Vec<(&'static str, String)>) -> Self

Add a constant field to every event.

§Example
let logger = tracing_logstash::Layer::default().event_format(
    tracing_logstash::logstash::LogstashFormat::default().with_constants(vec![
        ("service.name", "tracing-logstash".to_owned()),
    ]),
);
Source

pub fn span_format<FS2>(self, span_format: FS2) -> LogstashFormat<FC, FS2>

Trait Implementations§

Source§

impl Default for LogstashFormat

Source§

fn default() -> Self

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

impl<DFN, FS> FormatEvent for LogstashFormat<DFN, FS>

Source§

type R = DefaultSpanRecorder

Source§

fn span_recorder(&self) -> Self::R

Source§

fn format_event<S: Serializer, SS: Subscriber + for<'a> LookupSpan<'a>>( &self, serializer: S, event: &Event<'_>, ctx: Context<'_, SS>, ) -> Result<S::Ok, S::Error>

Auto Trait Implementations§

§

impl<FC, SF> Freeze for LogstashFormat<FC, SF>
where SF: Freeze, FC: Freeze,

§

impl<FC, SF> RefUnwindSafe for LogstashFormat<FC, SF>

§

impl<FC, SF> Send for LogstashFormat<FC, SF>
where SF: Send, FC: Send,

§

impl<FC, SF> Sync for LogstashFormat<FC, SF>
where SF: Sync, FC: Sync,

§

impl<FC, SF> Unpin for LogstashFormat<FC, SF>
where SF: Unpin, FC: Unpin,

§

impl<FC, SF> UnwindSafe for LogstashFormat<FC, SF>
where SF: UnwindSafe, FC: UnwindSafe,

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