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>
impl<FC, SF> LogstashFormat<FC, SF>
pub fn with_timestamp(self, display_timestamp: bool) -> Self
pub fn with_version(self, display_version: bool) -> Self
pub fn with_logger_name(self, display_logger_name: Option<LoggerName>) -> Self
pub fn with_thread_name(self, display_thread_name: bool) -> Self
pub fn with_level(self, display_level: bool) -> Self
pub fn with_level_value(self, display_level_value: bool) -> Self
pub fn with_span_list( self, display_span_list: Option<DisplayLevelFilter>, ) -> Self
pub fn with_stack_trace( self, display_stack_trace: Option<(DisplayLevelFilter, DisplayLevelFilter)>, ) -> Self
pub fn with_span_fields(self, span_fields: Vec<FieldSpec>) -> Self
Sourcepub fn with_field_contributor<FC2>(
self,
field_contributor: FC2,
) -> LogstashFormat<FC2, SF>
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),
);
Sourcepub fn with_constants(self, constants: Vec<(&'static str, String)>) -> Self
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()),
]),
);
pub fn span_format<FS2>(self, span_format: FS2) -> LogstashFormat<FC, FS2>
Trait Implementations§
Source§impl Default for LogstashFormat
impl Default for LogstashFormat
Source§impl<DFN, FS> FormatEvent for LogstashFormat<DFN, FS>where
FS: FormatSpan,
DFN: LogFieldContributor,
impl<DFN, FS> FormatEvent for LogstashFormat<DFN, FS>where
FS: FormatSpan,
DFN: LogFieldContributor,
type R = DefaultSpanRecorder
fn span_recorder(&self) -> Self::R
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>
impl<FC, SF> RefUnwindSafe for LogstashFormat<FC, SF>where
SF: RefUnwindSafe,
FC: RefUnwindSafe,
impl<FC, SF> Send for LogstashFormat<FC, SF>
impl<FC, SF> Sync for LogstashFormat<FC, SF>
impl<FC, SF> Unpin for LogstashFormat<FC, SF>
impl<FC, SF> UnwindSafe for LogstashFormat<FC, SF>where
SF: UnwindSafe,
FC: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more