[go: up one dir, main page]

Struct call_logger::CallLogger

source ·
pub struct CallLogger { /* private fields */ }
Expand description

Implements Log and some simple builder methods to configure.

Implementations§

source§

impl CallLogger

source

pub fn new() -> CallLogger

Creates a new CallLogger, use this along with the builder methods and then call init to set up the logger. The default timestamp format is utc epoch (if the timestamps feature is enabled), and the default call app that is called is echo.

Examples found in repository?
examples/log_to_discord.rs (line 5)
4
5
6
7
8
9
10
fn main() {
    let _ = CallLogger::new()
        .with_level(LevelFilter::Info)
        .with_call_target("examples/log_to_discord".to_string())
        .init();
    log::info!("Hello discord")
}
source

pub fn with_level(self, level: LevelFilter) -> CallLogger

The maximum log level that would be logged

Examples found in repository?
examples/log_to_discord.rs (line 6)
4
5
6
7
8
9
10
fn main() {
    let _ = CallLogger::new()
        .with_level(LevelFilter::Info)
        .with_call_target("examples/log_to_discord".to_string())
        .init();
    log::info!("Hello discord")
}
source

pub fn with_call_target(self, call_target: String) -> CallLogger

Sets the command line app or script that is called and passed the log details

Examples found in repository?
examples/log_to_discord.rs (line 7)
4
5
6
7
8
9
10
fn main() {
    let _ = CallLogger::new()
        .with_level(LevelFilter::Info)
        .with_call_target("examples/log_to_discord".to_string())
        .init();
    log::info!("Hello discord")
}
source

pub fn with_epoch_ms_timestamp(self) -> CallLogger

Sets the timestamp to the number of milliseconds since the epoch

source

pub fn with_epoch_us_timestamp(self) -> CallLogger

Sets the timestamp to the number of microseconds since the epoch

source

pub fn with_utc_timestamp(self) -> CallLogger

Sets the timestamp to a the UTC timezone

source

pub fn with_local_timestamp(self) -> CallLogger

Sets the timestamp to a the local timezone

source

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

This needs to be called after the builder has set up the logger

Examples found in repository?
examples/log_to_discord.rs (line 8)
4
5
6
7
8
9
10
fn main() {
    let _ = CallLogger::new()
        .with_level(LevelFilter::Info)
        .with_call_target("examples/log_to_discord".to_string())
        .init();
    log::info!("Hello discord")
}

Trait Implementations§

source§

impl Default for CallLogger

source§

fn default() -> Self

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

impl Log for CallLogger

source§

fn enabled(&self, _metadata: &Metadata<'_>) -> bool

Determines if a log message with the specified metadata would be logged. Read more
source§

fn log(&self, record: &Record<'_>)

Logs the Record. Read more
source§

fn flush(&self)

Flushes any buffered records.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.