Struct Glog

Source
pub struct Glog<T = UtcTime> { /* private fields */ }
Expand description

A glog-inspired span and event formatter.

Implementations§

Source§

impl<T> Glog<T>

Source

pub fn with_timer<T2>(self, timer: T2) -> Glog<T2>
where T2: FormatTime,

Use the given timer for span and event time stamps.

tracing-glog provides two timers: LocalTime and UtcTime. UtcTime is the default timer.

Source

pub fn with_thread_names(self, with_thread_names: bool) -> Glog<T>

Source

pub fn with_target(self, with_target: bool) -> Glog<T>

Source

pub fn with_span_names(self, with_span_names: bool) -> Glog<T>

Sets whether or not the span name is included. Defaults to true.

If span names are not included, then the fields from all spans are printed as a single list of fields. This results is a more compact output.

§Example Output

With with_span_names set to true:

I0731 16:23:45.674465 990039 examples/tokio.rs:38] [parent_task{subtasks: 10, reason: "testing"}, subtask{number: 10}] polling subtask, number: 10

With with_span_names set to false:

I0731 16:23:45.674465 990039 examples/tokio.rs:38] [subtasks: 10, reason: "testing", number: 10] polling subtask, number: 10
Source

pub fn with_span_context(self, with_span_context: bool) -> Glog<T>

Sets whether or not the span context is included. Defaults to true.

By default, formatters building atop of tracing_subscriber::fmt will include the span context as fmt::Layer and fmt::Subscriber assume that span context is is valuable and the raison d’être for using tracing and, as such, do not provide a toggle. However, users migrating from logging systems such as glog or folly’s xlog might find the span context to be overwhelming. Therefore, this formatter-level toggle is availible in order to provide a smoother onboarding experience to tracing.

Notice: This is a relatively coarse toggle. In most circumstances, usage of tracing-subscriber’s filter_fn is preferred to disable spans on a more fine-grained basis.

Source

pub fn with_format_level_chars( self, level_chars: &'static FormatLevelChars, ) -> Glog<T>

Sets the characters to use to indicate the level for each event. Defaults to the initial character of the level.

Trait Implementations§

Source§

impl Default for Glog<UtcTime>

Source§

fn default() -> Self

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

impl<S, N, T> FormatEvent<S, N> for Glog<T>
where S: Subscriber + for<'a> LookupSpan<'a>, N: for<'a> FormatFields<'a> + 'static, T: FormatTime,

Source§

fn format_event( &self, ctx: &FmtContext<'_, S, N>, writer: Writer<'_>, event: &Event<'_>, ) -> Result

Write a log message for Event in Context to the given Writer.

Auto Trait Implementations§

§

impl<T> Freeze for Glog<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Glog<T>
where T: RefUnwindSafe,

§

impl<T> Send for Glog<T>
where T: Send,

§

impl<T> Sync for Glog<T>
where T: Sync,

§

impl<T> Unpin for Glog<T>
where T: Unpin,

§

impl<T> UnwindSafe for Glog<T>
where T: 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> 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, 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<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