Struct LogBuilder

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

Implementations§

Source§

impl LogBuilder

Source

pub fn new(default_logging_targets: Vec<(String, Level)>) -> Self

Create a new builder Provide the default_logging_targets that are used if the ANT_LOG env variable is not set.

By default, we use log to the StdOut with the default format.

Source

pub fn output_dest(&mut self, output_dest: LogOutputDest)

Set the logging output destination

Source

pub fn format(&mut self, format: LogFormat)

Set the logging format

Source

pub fn max_log_files(&mut self, files: usize)

The max number of uncompressed log files to store

Source

pub fn max_archived_log_files(&mut self, files: usize)

The max number of compressed files to store

Source

pub fn print_updates_to_stdout(&mut self, print: bool)

Setting this to false would prevent ant_logging from printing things to stdout.

Source

pub fn initialize(self) -> Result<(ReloadHandle, Option<WorkerGuard>), Error>

Inits node logging, returning the NonBlocking guard if present. This guard should be held for the life of the program.

Logging should be instantiated only once.

Source

pub fn init_single_threaded_tokio_test( test_file_name: &str, disable_networking_logs: bool, ) -> (Option<WorkerGuard>, DefaultGuard)

Logs to the data_dir. Should be called from a single threaded tokio/non-tokio context. Provide the test file name to capture tracings from the test.

subscriber.set_default() should be used if under a single threaded tokio / single threaded non-tokio context. Refer here for more details: https://github.com/tokio-rs/tracing/discussions/1626

Source

pub fn init_multi_threaded_tokio_test( test_file_name: &str, disable_networking_logs: bool, ) -> Option<WorkerGuard>

Logs to the data_dir. Should be called from a multi threaded tokio context. Provide the test file name to capture tracings from the test.

subscriber.init() should be used under multi threaded tokio context. If you have 1+ multithreaded tokio tests under the same integration test, this might result in loss of logs. Hence use .init() (instead of .try_init()) to panic if called more than once.

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