pub struct LogWriter {
pub log_path: PathBuf,
pub line_count: u64,
pub line_maximum: u64,
pub current_log_file_number: i64,
pub log_file: File,
pub rx: Receiver<String>,
}
Expand description
General Information
Struct that writes logs to files. Changes files when maximum number of lines has been reached.
Fields
log_path
- Direction in which files will be generatedline_count
- Number of lines currently writtenline_maximum
- Maximum number of lines per filecurrent_log_file_number
- Number of current file in which logs are being writtenlog_file
- Current log filerx
- Used for internal communication between log, warn and error in this structure
Fields§
§log_path: PathBuf
§line_count: u64
§line_maximum: u64
§current_log_file_number: i64
§log_file: File
§rx: Receiver<String>
Implementations§
source§impl LogWriter
impl LogWriter
sourcepub fn new(
log_path: PathBuf,
rx: Receiver<String>,
line_maximum: u64
) -> LogWriter
pub fn new(
log_path: PathBuf,
rx: Receiver<String>,
line_maximum: u64
) -> LogWriter
General Information
Creates new instance of LogWriter while taking into account previous log files, last log file and state of last log file
Parameters
log_path
- A path-like object where all logs remainrx
- A receiver for internal communicationline_maximum
- Maximum number of lines for log file
sourcepub fn run(&mut self)
pub fn run(&mut self)
General Information
Writes to log file and changes internal values like line number and log file if necessary
Parameters
&mut self
- A mutable reference to write and change internal state