Skip to main content

RichHandler

Struct RichHandler 

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

Renders log events like upstream’s RichHandler.

Implementations§

Source§

impl RichHandler

Source

pub fn new(console: Console) -> Self

A handler printing to console, with upstream’s defaults: time, level and path shown, repeated times omitted, ReprHighlighter, no markup, KEYWORDS highlighted and paths linked.

Source

pub fn span_view(self, view: SpanView) -> Self

How an event’s spans are shown (default SpanView::Inline).

Source

pub fn hyperlinker(self, hyperlinker: Hyperlinker) -> Self

Link the path column through hyperlinker instead of a bare file:// URL: its editor template, base directory for relative paths (as tracing reports them) and on/off switch apply.

Source

pub fn live<W: Write + Send + 'static>( self, live: Arc<Mutex<LiveCoordinator<W>>>, ) -> Self

Print through live, above its regions, so log lines never tear a live display. Render with a console as wide as live’s target (see RenderTarget::console); longer lines fold. The coordinator refuses control codes, so any in a line (a message, field, span or path) are shown as symbols instead: every line prints.

Source

pub fn show_time(self, show: bool) -> Self

Show the time column (upstream show_time).

Source

pub fn show_level(self, show: bool) -> Self

Show the level column (upstream show_level).

Source

pub fn show_path(self, show: bool) -> Self

Show the path column (upstream show_path).

Source

pub fn omit_repeated_times(self, omit: bool) -> Self

Blank a time equal to the previous record’s (upstream omit_repeated_times).

Source

pub fn level_width(self, width: Option<usize>) -> Self

The level column’s width, or None to fit (upstream log_time_format’s sibling level_width, fixed at 8 upstream).

Source

pub fn markup(self, markup: bool) -> Self

Parse messages as console markup (upstream markup).

Source

pub fn highlighter( self, highlighter: Option<Box<dyn Highlighter + Send + Sync>>, ) -> Self

The message highlighter, or None for none (upstream highlighter).

Source

pub fn keywords<I, S>(self, keywords: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Words styled logging.keyword (upstream keywords).

Link the path column to the source file (upstream enable_link_path).

Source

pub fn time_format( self, format: impl Fn() -> String + Send + Sync + 'static, ) -> Self

Format the current time for events without a timestamp (upstream log_time_format).

Source

pub fn level_text(severity: Severity) -> Text

The level column. Port of RichHandler.get_level_text, with Python’s level names (WARNING, CRITICAL); TRACE uses logging.level.notset.

Source

pub fn render_message(&self, event: &StructuredEvent) -> Text

The message column. Port of RichHandler.render_message; structured fields follow the message as key=value.

Source

pub fn render(&self, event: &StructuredEvent) -> Table

Lay out one event. Port of RichHandler.render.

Source

pub fn emit_event(&self, event: &StructuredEvent)

Print one event. Port of RichHandler.emit.

Trait Implementations§

Source§

impl EventSink for RichHandler

Available on crate features log or tracing only.
Source§

fn emit(&self, event: StructuredEvent) -> Result<()>

Auto Trait Implementations§

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 = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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