Compare commits

...

2 Commits

Author SHA1 Message Date
dd5bfff7d2
replaced log_message with new log!
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
2024-02-15 22:41:13 +01:00
927a8d6d05
rustdoc adjustments 2024-02-15 22:40:58 +01:00
3 changed files with 19 additions and 7 deletions

View File

@ -1,5 +1,14 @@
/*! /*!
* Containing all singleton and thread-safe structs related to configuring `WANessa`. * Containing all singleton and thread-safe structs related to configuring `WANessa`.
*
* This crate differentiates between `Configs` and `Settings`:
* Configs:
* - Configs are immutable after they have been initialized. Example [`DbConfig`].
* - Changing the config requires a restart of `WANessa`.
*
* Settings:
* - Settings are mutable after they have been initialized. Example [`LogSettings`].
* - `WANessa` always uses the current setting and does not need a restart to apply new settings.
*/ */
pub mod db; pub mod db;

View File

@ -1,6 +1,6 @@
/*! /*!
* This module handles logging messages asynchronously and is thread-safe. * This module handles logging messages asynchronously and is thread-safe.
* It should mostly be called statically. * It should mostly be called statically using the [`log!`] macro.
*/ */
mod test; mod test;
@ -92,7 +92,10 @@ pub fn log_to_str(
} }
/** /**
* Shorthand version for [`log_message`], which does not require information about the [`config::Config::log_location`]. * Shorthand version for [`log_message`], which does not require information about where in the code
* the command was called from.
* Tries to aqcuire a read lock, if a reference to an instance of [`config::log::LogSettings`] is
* not given.
*/ */
#[macro_export] #[macro_export]
macro_rules! log { macro_rules! log {
@ -109,7 +112,7 @@ macro_rules! log {
} }
/** /**
* A named typle assigning a log [`LogVerbosity`] to a [`LogMessageType`] * A named typle assigning a log [`LogVerbosity`] to a [`LogMessageType`].
*/ */
#[derive(PartialEq, Eq, Debug)] #[derive(PartialEq, Eq, Debug)]
pub struct LogMessage(LogMessageType, LogVerbosity); pub struct LogMessage(LogMessageType, LogVerbosity);

View File

@ -67,7 +67,7 @@ pub fn log_msg_file() {
create_dir_all(PathBuf::from(LOG_DIR.as_str())) create_dir_all(PathBuf::from(LOG_DIR.as_str()))
.unwrap_or_else(|_| panic!("Could not create directory: {}", *LOG_DIR)); .unwrap_or_else(|_| panic!("Could not create directory: {}", *LOG_DIR));
log_message(&message, &config, file!(), line!(), column!()); log!(&message, &config);
let log_file = read_to_string(PathBuf::from(log_path)) let log_file = read_to_string(PathBuf::from(log_path))
.unwrap_or_else(|_| panic!("Could not read file: {log_path}")); .unwrap_or_else(|_| panic!("Could not read file: {log_path}"));
@ -91,7 +91,7 @@ pub fn log_str() {
.expect("There should be a log line.") .expect("There should be a log line.")
+ "\n"; + "\n";
log_message(&message, &config, file!(), line!(), column!()); log!(&message, &config);
let log_file = read_to_string(PathBuf::from(log_path)) let log_file = read_to_string(PathBuf::from(log_path))
.unwrap_or_else(|_| panic!("Could not read file: {log_path}")); .unwrap_or_else(|_| panic!("Could not read file: {log_path}"));
@ -122,7 +122,7 @@ pub fn verbosity_no_filter() {
+ "\n"; + "\n";
for msg in messages { for msg in messages {
log_message(&msg, &config, file!(), line!(), column!()); log!(&msg, &config);
} }
let log_file = read_to_string(PathBuf::from(log_path)) let log_file = read_to_string(PathBuf::from(log_path))
@ -156,7 +156,7 @@ pub fn verbosity_filter() {
+ "\n"); + "\n");
for msg in messages { for msg in messages {
log_message(&msg, &config, file!(), line!(), column!()); log!(&msg, &config);
} }
let log_file = read_to_string(PathBuf::from(log_path)) let log_file = read_to_string(PathBuf::from(log_path))