Struct std_logger::Config

source ·
pub struct Config<F, Kvs> { /* private fields */ }
Expand description

Configuration of the logger.

It support three logging formats:

Implementations§

source§

impl Config<(), NoKvs>

source

pub fn logfmt() -> Config<LogFmt, NoKvs>

source

pub fn json() -> Config<Json, NoKvs>

Structured logging using JSON.

source

pub fn gcloud() -> Config<Gcloud, NoKvs>

Google Cloud Platform structured logging using JSON, following https://cloud.google.com/logging/docs/structured-logging.

source§

impl<F, Kvs> Config<F, Kvs>
where F: Format + Send + Sync + 'static, Kvs: Source + Send + Sync + 'static,

source

pub fn with_kvs<K>(self, kvs: K) -> Config<F, K>
where K: Source + Send + Sync + 'static,

Add the key-values kvs to all logged messages.

source

pub fn with_call_location(self, enable: bool) -> Config<F, Kvs>

Enable or disable logging of the call location.

Default to enable if the debug (or lower) messages are enabled.

source

pub fn init(self)

Initialise the logger.

See the crate level documentation for more.

§Panics

This will panic if the logger fails to initialise. Use Config::try_init if you want to handle the error yourself.

source

pub fn try_init(self) -> Result<(), SetLoggerError>

Try to initialise the logger.

Unlike Config::init this doesn’t panic when the logger fails to initialise. See the crate level documentation for more.

Trait Implementations§

source§

impl<F: Debug, Kvs: Debug> Debug for Config<F, Kvs>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<F, Kvs> RefUnwindSafe for Config<F, Kvs>

§

impl<F, Kvs> Send for Config<F, Kvs>
where F: Send, Kvs: Send,

§

impl<F, Kvs> Sync for Config<F, Kvs>
where F: Sync, Kvs: Sync,

§

impl<F, Kvs> Unpin for Config<F, Kvs>
where F: Unpin, Kvs: Unpin,

§

impl<F, Kvs> UnwindSafe for Config<F, Kvs>
where F: UnwindSafe, Kvs: 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>,

§

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

§

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.