Logging #26

Open
leon wants to merge 33 commits from Logging into main
Showing only changes of commit a3fe0d0686 - Show all commits

View File

@ -2,6 +2,7 @@
* A singleton, thread-safe struct used for accessing
*/
use std::path::Path;
use std::path::PathBuf;
use std::sync::RwLock;
@ -37,6 +38,7 @@ pub struct Config {
log_location: bool,
/// If `Some(path)` tries to also write the log to `path` in addition to stderr/stderr.<br>
/// Default: [None]
#[getset(skip)]
log_path: Option<PathBuf>,
/// Logs to standard out, if true.<br>
/// Default: `true`
@ -69,14 +71,26 @@ impl Config {
/// Getter for [`Self::log_time_format`].
#[must_use]
pub fn log_time_format(&self) -> &str {
todo!();
// self.log_time_format.as_ref().map_or("%F-%T:%f", |fmt| fmt)
self.log_time_format.as_ref().map_or("%F-%T:%f", |fmt| fmt)
}
/// Setter for [`Self::log_time_format`].
pub fn set_log_time_format(&mut self, format: impl Into<String>) {
self.log_time_format = Some(format.into());
}
/// Getter for [`Self::log_path`].
#[must_use]
pub fn log_path(&self) -> Option<&Path>
{
self.log_path.as_deref()
}
/// Setter for [`Self::log_path`].
pub fn set_log_path(&mut self, log_path: impl Into<Option<PathBuf>>)
{
self.log_path = log_path.into();
}
}
/// See [`DEFAULTS`].