Struct Config

Source
pub struct Config { /* private fields */ }
Expand description

Configuration of a logger instance.

Implementations§

Source§

impl Config

Source

pub fn new() -> Self

Constructs a new Config.

Source

pub fn use_mmap(self, flag: bool) -> Self

Whether or not to use mmap as the underlying storage for the buffer.

With mmap, if the application terminates unexpectedly, the log data in the buffer is written to the mmap buffer file by the OS at a certain time, and then when the logger is restarted, the log data is written back to the log file, avoiding loss of log data.

It is enabled by default.

Source

pub fn buffer_len(self, len: usize) -> Self

The buffer length.

If mmap is used, it is rounded up to a multiple of pagesize. Pinenut uses a double cache system, so the buffer that is actually written to will be less than half of this.

The default value is 320 KB.

Source

pub fn rotation(self, rotation: TimeDimension) -> Self

Time granularity of log extraction.

The default value is Minute.

Source

pub fn key(self, key: Option<PublicKey>) -> Self

The encryption key, the public key in ECDH.

It is used to negotiate the key for symmetric encryption of the log. If the value is None, there is no encryption.

The default value is None.

Source

pub fn key_str(self, key: Option<impl AsRef<[u8]>>) -> Self

The encryption key, the public key in ECDH, represented in Base64.

It is used to negotiate the key for symmetric encryption of the log. If the value is None or invalid, there is no encryption.

The default value is None.

Source

pub fn compression_level(self, level: i32) -> Self

The compression level.

Pinenut uses zstd as the compression algorithm, which supports compression levels from 1 up to 22, it also offers negative compression levels.

As the std’s documentation says: The lower the level, the faster the speed (at the cost of compression).

The default value is 10.

Source

pub fn tracker(self, tracker: Option<Tracker>) -> Self

The tracker used to track errors occurred from the logger operations.

Errors are printed to standard output by default.

Source

pub fn logger(self, domain: Domain) -> Logger

Obtains a logger with a specified domain.

Trait Implementations§

Source§

impl Default for Config

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl Freeze for Config

§

impl !RefUnwindSafe for Config

§

impl Send for Config

§

impl Sync for Config

§

impl Unpin for Config

§

impl !UnwindSafe for Config

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> Same for T

Source§

type Output = T

Should always be Self
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.