Skip to main content

FileLogger

Struct FileLogger 

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

Main configuration structure for log file output.

Controls where logs are stored and their maximum size limits. Use FileLogger::new() to create an instance with custom settings.

Accessors are generated by #[derive(Data)]; the String setters accept any impl AsRef<str> via #[set(type(AsRef<str>))].

Implementations§

Source§

impl FileLogger

Source

pub fn new<P: AsRef<str>>(path: P, limit_file_size: usize) -> Self

Creates new FileLogger configuration with specified parameters.

§Arguments
  • P - The path for storing log files, which will be converted to string slice.
  • usize - The maximum file size limit in bytes.
§Returns
  • Self - A new FileLogger instance with specified configuration.
Source

pub fn is_enable(&self) -> bool

Checks if logging is enabled.

§Returns
  • bool - True if logging is enabled.
Source

pub fn is_disable(&self) -> bool

Checks if logging is disabled.

§Returns
  • bool - True if logging is disabled.
Source

pub fn trace<T, L>(&self, data: T, func: L) -> &Self
where T: AsRef<str>, L: FileLoggerFuncTrait<T>,

Logs trace message synchronously.

§Arguments
  • T - Trace data to be logged, which will be converted to string slice.
  • L - FileLogger formatting function.
§Returns
  • &Self - Reference to self.
Source

pub async fn async_trace<T, L>(&self, data: T, func: L) -> &Self
where T: AsRef<str>, L: FileLoggerFuncTrait<T>,

Logs trace message asynchronously.

§Arguments
  • T - Trace data to be logged, which will be converted to string slice.
  • L - FileLogger formatting function.
§Returns
  • &Self - Reference to self.
Source

pub fn debug<T, L>(&self, data: T, func: L) -> &Self
where T: AsRef<str>, L: FileLoggerFuncTrait<T>,

Logs debug message synchronously.

§Arguments
  • T - Debug data to be logged, which will be converted to string slice.
  • L - FileLogger formatting function.
§Returns
  • &Self - Reference to self.
Source

pub async fn async_debug<T, L>(&self, data: T, func: L) -> &Self
where T: AsRef<str>, L: FileLoggerFuncTrait<T>,

Logs debug message asynchronously.

§Arguments
  • T - Debug data to be logged, which will be converted to string slice.
  • L - FileLogger formatting function.
§Returns
  • &Self - Reference to self.
Source

pub fn info<T, L>(&self, data: T, func: L) -> &Self
where T: AsRef<str>, L: FileLoggerFuncTrait<T>,

Logs info message synchronously.

§Arguments
  • T - Info data to be logged, which will be converted to string slice.
  • L - FileLogger formatting function.
§Returns
  • &Self - Reference to self.
Source

pub async fn async_info<T, L>(&self, data: T, func: L) -> &Self
where T: AsRef<str>, L: FileLoggerFuncTrait<T>,

Logs info message asynchronously.

§Arguments
  • T - Info data to be logged, which will be converted to string slice.
  • L - FileLogger formatting function.
§Returns
  • &Self - Reference to self.
Source

pub fn warn<T, L>(&self, data: T, func: L) -> &Self
where T: AsRef<str>, L: FileLoggerFuncTrait<T>,

Logs warn message synchronously.

§Arguments
  • T - Warn data to be logged, which will be converted to string slice.
  • L - FileLogger formatting function.
§Returns
  • &Self - Reference to self.
Source

pub async fn async_warn<T, L>(&self, data: T, func: L) -> &Self
where T: AsRef<str>, L: FileLoggerFuncTrait<T>,

Logs warn message asynchronously.

§Arguments
  • T - Warn data to be logged, which will be converted to string slice.
  • L - FileLogger formatting function.
§Returns
  • &Self - Reference to self.
Source

pub fn error<T, L>(&self, data: T, func: L) -> &Self
where T: AsRef<str>, L: FileLoggerFuncTrait<T>,

Logs error message synchronously.

§Arguments
  • T - Error data to be logged, which will be converted to string slice.
  • L - FileLogger formatting function.
§Returns
  • &Self - Reference to self.
Source

pub async fn async_error<T, L>(&self, data: T, func: L) -> &Self
where T: AsRef<str>, L: FileLoggerFuncTrait<T>,

Logs error message asynchronously.

§Arguments
  • T - Error data to be logged, which will be converted to string slice.
  • L - FileLogger formatting function.
§Returns
  • &Self - Reference to self.
Source§

impl FileLogger

Source

pub fn set_path(&mut self, val: impl AsRef<str>) -> &mut Self

Source

pub fn get_path(&self) -> &String

Source

pub fn get_mut_path(&mut self) -> &mut String

Source

pub fn get_limit_file_size(&self) -> &usize

Source

pub fn get_mut_limit_file_size(&mut self) -> &mut usize

Source

pub fn set_limit_file_size(&mut self, val: usize) -> &mut Self

Source

pub fn set_trace_dir(&mut self, val: impl AsRef<str>) -> &mut Self

Source

pub fn get_trace_dir(&self) -> &String

Source

pub fn get_mut_trace_dir(&mut self) -> &mut String

Source

pub fn set_debug_dir(&mut self, val: impl AsRef<str>) -> &mut Self

Source

pub fn get_debug_dir(&self) -> &String

Source

pub fn get_mut_debug_dir(&mut self) -> &mut String

Source

pub fn set_info_dir(&mut self, val: impl AsRef<str>) -> &mut Self

Source

pub fn get_info_dir(&self) -> &String

Source

pub fn get_mut_info_dir(&mut self) -> &mut String

Source

pub fn set_warn_dir(&mut self, val: impl AsRef<str>) -> &mut Self

Source

pub fn get_warn_dir(&self) -> &String

Source

pub fn get_mut_warn_dir(&mut self) -> &mut String

Source

pub fn set_error_dir(&mut self, val: impl AsRef<str>) -> &mut Self

Source

pub fn get_error_dir(&self) -> &String

Source

pub fn get_mut_error_dir(&mut self) -> &mut String

Trait Implementations§

Source§

impl Clone for FileLogger

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for FileLogger

Default implementation for FileLogger configuration.

Source§

fn default() -> Self

Creates default FileLogger configuration.

§Returns
  • Self - Default FileLogger instance with default path and file size limit.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

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 T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.