[][src]Struct fast_logger::LoggerV2Async

pub struct LoggerV2Async<C: Display + Send> { /* fields omitted */ }

The fastest logger in the west

A very simple logger that uses a custom structure and a logging level. No further assumptions are made about the structure or nature of the logging message, thus making it extremely cheap to send messages to the logger thread.

Methods

impl<C: 'static + Display + Send> LoggerV2Async<C>[src]

pub fn spawn() -> Logger<C>[src]

Create a logger object and spawn a logging thread

The logger object is the interface to write stuff to the logger thread. The logger thread is in the background, waiting for messages to print out. Once all logger objects are dropped, the thread will die.

Typically, you only call spawn once in an application since you just want a single logging thread to print stuff.

pub fn spawn_with_writer<T: 'static + Write + Send>(writer: T) -> Logger<C>[src]

Create a logger object with a specific writer

See spawn for more information regarding spawning. This function providing the logger a writer, which makes the logger use any arbitrary writing interface.

pub fn spawn_void() -> Logger<C>[src]

Spawn a logger that doesn't output anything

This logger automatically sets the log level to 0, if you set the log level to something other than that the message will be sent, but it will be completely ignored.

pub fn spawn_test() -> Logger<C>[src]

Create a logger object for tests

Similar to spawn but sets the log level to 255 and enables colored output, logs to stderr.

pub fn set_log_level(&mut self, level: u8)[src]

The log-level is an 8-bit variable that is shared among all clones of this logger. When we try logging we first check if our message has a priority higher or equal to this level. If it doesn't we just exit the logger function.

Internally, we use an atomic variable to store the logging level so all threads can check it quickly. This makes log statements that won't trigger because of the log-level absolutely fucking NUTS (so cheap it's basically non-existent).

pub fn get_log_level(&self) -> u8[src]

Retrieve the current global log level value

pub fn set_context_specific_log_level(&mut self, ctx: &'static str, level: u8)[src]

Sets the log level for a specific context

Whenever the logger receives a message, it will use the context-to-level mapping to see if the message should be logged or not. Note that this happens after checking the global log level.

pub fn set_colorize(&mut self, on: bool)[src]

Enable colorizing log output

pub fn get_colorize(&mut self) -> bool[src]

Check the current colorization status

impl<C: 'static + Display + Send> LoggerV2Async<C>[src]

pub fn log(&mut self, level: u8, ctx: &'static str, message: impl Into<C>)[src]

Generic logging function

Send a message with a specific log-level.

pub fn trace(&mut self, ctx: &'static str, message: impl Into<C>)[src]

Log an error message (level 255)

Does nothing when compiled without debug assertions

pub fn debug(&mut self, ctx: &'static str, message: impl Into<C>)[src]

Log an error message (level 192)

pub fn info(&mut self, ctx: &'static str, message: impl Into<C>)[src]

Log an error message (level 128)

pub fn warn(&mut self, ctx: &'static str, message: impl Into<C>)[src]

Log an error message (level 64)

pub fn error(&mut self, ctx: &'static str, message: impl Into<C>)[src]

Log an error message (level 0)

impl<C: 'static + Display + Send + From<String>> LoggerV2Async<C>[src]

pub fn make_writer(&mut self, ctx: &'static str, level: u8) -> impl Write + '_[src]

Create a writer proxy for this logger

Can be used to de-couple the logger dependency by passing aroung a writer instead of this logger.

Trait Implementations

impl<C: 'static + Display + From<Generic> + Send> GenericLogger for LoggerV2Async<C>[src]

impl<C: Clone + Display + Send> Clone for LoggerV2Async<C>[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl<C> Unpin for LoggerV2Async<C> where
    C: Unpin

impl<C> Sync for LoggerV2Async<C>

impl<C> Send for LoggerV2Async<C>

impl<C> !RefUnwindSafe for LoggerV2Async<C>

impl<C> !UnwindSafe for LoggerV2Async<C>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]