MessageBuilder

Struct MessageBuilder 

Source
pub struct MessageBuilder { /* private fields */ }

Implementations§

Source§

impl MessageBuilder

Source

pub fn new() -> Self

Creates a new MessageBuilder with the following defaults:

  • Level -> Level’s default
  • Author -> The hostname of the OS or ‘?’ if that cannot be retrieved
Source

pub fn body<F>(&mut self, apply: F) -> &mut Self

Add a message body to the message builder If not set it will be blank.

Source

pub fn level(&mut self, level: Level) -> &mut Self

Set the message Level

Source

pub fn title<S: ToString>(&mut self, title: S) -> &mut Self

Sets the title of the message, If not set, will be blank.

Source

pub fn component(&mut self, component: Component) -> &mut Self

Sets the Component of the message By default the component will be blank

Source

pub fn author<S: ToString>(&mut self, parts: S) -> &mut Self

Adds Author data to the message. By default this is just the hostname of OS running it (‘?’ if this cannot be retrieved) The argument parts is appended onto this hostname data (with a ‘/’)

Source

pub fn timestamp(&mut self, unix_timestamp_millis: i64) -> &mut Self

Sets the timestamp of the message. This is set by default to the time which the MessageBuilder was created.

However, if you are using build_clone you should be using this if you don’t want your messages to all have the same timestamp.

Source

pub fn build(self) -> Message

Builds the message, consuming the MessageBuilder If timestamp has been set, it will be used, otherwise the current time will be retrieved and used.

Source

pub fn build_clone(&self) -> Message

Builds a new message, without consuming the MessageBuilder If timestamp has been set, it will be used, otherwise the current time will be retrieved and used.

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