Compare commits
2 Commits
cbfa4cbfdf
...
dd5bfff7d2
Author | SHA1 | Date | |
---|---|---|---|
dd5bfff7d2 | |||
927a8d6d05 |
@ -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;
|
||||||
|
@ -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);
|
||||||
|
@ -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))
|
||||||
|
Reference in New Issue
Block a user