pub struct LoggerV2Async<C: Display + Send> { /* private fields */ }
Expand description

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.

Implementations§

source§

impl<C: 'static + Display + Send> LoggerV2Async<C>

source

pub fn spawn(ctx: &'static str) -> Logger<C>

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.

source

pub fn spawn_with_writer<T: 'static + Write + Send>( ctx: &'static str, writer: T ) -> Logger<C>

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.

source

pub fn spawn_void() -> Logger<C>

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.

source

pub fn spawn_test() -> Logger<C>

Create a logger object for tests

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

source

pub fn clone_with_context(&self, ctx: &'static str) -> Self

Clone the logger but change the context of the clone

source

pub fn clone_add_context(&self, ctx: &'static str) -> Self

Clone the logger but append the context of the clone

source

pub fn set_log_level(&self, level: u8)

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).

source

pub fn get_log_level(&self) -> u8

Retrieve the current global log level value

source

pub fn set_context_specific_log_level(&self, ctx: &str, level: u8) -> bool

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.

source

pub fn set_this_log_level(&self, level: u8)

Set the log level of this logger’s associated context

source

pub fn set_colorize(&self, on: bool)

Enable colorizing log output

source

pub fn get_colorize(&self) -> bool

Check the current colorization status

source§

impl<C: 'static + Display + Send> LoggerV2Async<C>

source

pub fn log(&self, level: u8, message: impl Into<C>)

Generic logging function

Send a message with a specific log-level.

source

pub fn trace(&self, message: impl Into<C>)

Log an error message (level 255)

Does nothing when compiled without debug assertions

source

pub fn debug(&self, message: impl Into<C>)

Log an error message (level 192)

source

pub fn info(&self, message: impl Into<C>)

Log an error message (level 128)

source

pub fn warn(&self, message: impl Into<C>)

Log an error message (level 64)

source

pub fn error(&self, message: impl Into<C>)

Log an error message (level 0)

source§

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

source

pub fn make_writer(&self, level: u8) -> impl Write + '_

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§

source§

impl<C: Clone + Display + Send> Clone for LoggerV2Async<C>

source§

fn clone(&self) -> LoggerV2Async<C>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

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

source§

fn log_generic(&self, level: u8, message: Generic)

Log a generic message, used by Logpass
source§

fn to_logpass(self) -> Logpass

Consume this logger to create a logpass
source§

fn to_compatibility(self) -> Compatibility

Turn the logger into a function that takes messages Read more

Auto Trait Implementations§

§

impl<C> !RefUnwindSafe for LoggerV2Async<C>

§

impl<C> Send for LoggerV2Async<C>

§

impl<C> Sync for LoggerV2Async<C>

§

impl<C> Unpin for LoggerV2Async<C>

§

impl<C> !UnwindSafe for LoggerV2Async<C>

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.