pub struct Logger { /* private fields */ }Expand description
Application logger.
When debug_assertions are enabled tracing output is written
to stdout and to disc; for release builds tracing is just written
to disc.
Implementations§
Source§impl Logger
impl Logger
Sourcepub fn new(name: Option<String>) -> Self
pub fn new(name: Option<String>) -> Self
Create a new logger using default paths.
§Panics
If the default data directory could not be determined.
Sourcepub fn new_paths(paths: Arc<Paths>, name: Option<String>) -> Self
pub fn new_paths(paths: Arc<Paths>, name: Option<String>) -> Self
Create a new logger with the given paths.
Sourcepub fn new_dir(logs_dir: PathBuf, name: String) -> Self
pub fn new_dir(logs_dir: PathBuf, name: String) -> Self
Create a new logger with the given directory and file name.
Sourcepub fn init_subscriber(
&self,
default_log_level: Option<String>,
) -> Result<(), Error>
Available on debug-assertions enabled only.
pub fn init_subscriber( &self, default_log_level: Option<String>, ) -> Result<(), Error>
Initialize the tracing subscriber.
Sourcepub fn init_file_subscriber(
&self,
default_log_level: Option<String>,
) -> Result<(), Error>
pub fn init_file_subscriber( &self, default_log_level: Option<String>, ) -> Result<(), Error>
Initialize a subscriber that writes to a file.
Sourcepub fn status(&self) -> Result<LogFileStatus, Error>
pub fn status(&self) -> Result<LogFileStatus, Error>
Log file status.
Sourcepub fn tail(&self, num_lines: Option<usize>) -> Result<Vec<String>, Error>
pub fn tail(&self, num_lines: Option<usize>) -> Result<Vec<String>, Error>
Load the tail of log records for the current file.
Sourcepub fn tail_file(
&self,
num_lines: Option<usize>,
path: impl AsRef<Path>,
) -> Result<Vec<String>, Error>
pub fn tail_file( &self, num_lines: Option<usize>, path: impl AsRef<Path>, ) -> Result<Vec<String>, Error>
Load the tail of log records for a file.
Sourcepub fn delete_logs(&self) -> Result<(), Error>
pub fn delete_logs(&self) -> Result<(), Error>
Delete all log files except the current log file.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Logger
impl RefUnwindSafe for Logger
impl Send for Logger
impl Sync for Logger
impl Unpin for Logger
impl UnwindSafe for Logger
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more