refactor: Added a debug line for logging to output the config used when starting Managarr
This commit is contained in:
Generated
+22
@@ -1359,6 +1359,7 @@ dependencies = [
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"urlencoding",
|
||||
"veil",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2644,6 +2645,27 @@ version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
|
||||
|
||||
[[package]]
|
||||
name = "veil"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f00796f9c5969da55497f5c8802c2e69eaf21c0166fe28b6006c7c4699f4d0e"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"veil-macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "veil-macros"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5b2d5567b6fbd34e8f0488d56b648e67c0d999535f4af2060d14f9074b43e833"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.90",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wait-timeout"
|
||||
version = "0.2.0"
|
||||
|
||||
@@ -54,6 +54,7 @@ derive_setters = "0.1.6"
|
||||
deunicode = "1.6.0"
|
||||
paste = "1.0.15"
|
||||
openssl = { version = "0.10.68", features = ["vendored"] }
|
||||
veil = "0.2.0"
|
||||
|
||||
[dev-dependencies]
|
||||
assert_cmd = "2.0.16"
|
||||
|
||||
+21
-1
@@ -2,7 +2,7 @@
|
||||
mod tests {
|
||||
use crate::models::Route;
|
||||
use anyhow::anyhow;
|
||||
use pretty_assertions::assert_eq;
|
||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||
use rstest::rstest;
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
@@ -347,4 +347,24 @@ mod tests {
|
||||
assert!(servarr_config.api_token.is_empty());
|
||||
assert_eq!(servarr_config.ssl_cert_path, None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_servarr_config_redacted_debug() {
|
||||
let host = "localhost".to_owned();
|
||||
let port = 1234;
|
||||
let uri = "http://localhost:1234".to_owned();
|
||||
let api_token = "thisisatest".to_owned();
|
||||
let ssl_cert_path = "/some/path".to_owned();
|
||||
let expected_str = format!("ServarrConfig {{ host: Some(\"{}\"), port: Some({}), uri: Some(\"{}\"), api_token: \"***********\", ssl_cert_path: Some(\"{}\") }}",
|
||||
host, port, uri, ssl_cert_path);
|
||||
let servarr_config = ServarrConfig {
|
||||
host: Some(host),
|
||||
port: Some(port),
|
||||
uri: Some(uri),
|
||||
api_token,
|
||||
ssl_cert_path: Some(ssl_cert_path),
|
||||
};
|
||||
|
||||
assert_str_eq!(format!("{servarr_config:?}"), expected_str);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -6,6 +6,7 @@ use log::{debug, error};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tokio::sync::mpsc::Sender;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use veil::Redact;
|
||||
|
||||
use crate::app::context_clues::{build_context_clue_string, SERVARR_CONTEXT_CLUES};
|
||||
use crate::cli::Command;
|
||||
@@ -258,11 +259,12 @@ impl AppConfig {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone)]
|
||||
#[derive(Redact, Deserialize, Serialize, Clone)]
|
||||
pub struct ServarrConfig {
|
||||
pub host: Option<String>,
|
||||
pub port: Option<u16>,
|
||||
pub uri: Option<String>,
|
||||
#[redact]
|
||||
pub api_token: String,
|
||||
pub ssl_cert_path: Option<String>,
|
||||
}
|
||||
|
||||
+2
-1
@@ -13,7 +13,7 @@ use crossterm::execute;
|
||||
use crossterm::terminal::{
|
||||
disable_raw_mode, enable_raw_mode, EnterAlternateScreen, LeaveAlternateScreen,
|
||||
};
|
||||
use log::{error, warn};
|
||||
use log::{debug, error, warn};
|
||||
use network::NetworkTrait;
|
||||
use ratatui::backend::CrosstermBackend;
|
||||
use ratatui::Terminal;
|
||||
@@ -93,6 +93,7 @@ async fn main() -> Result<()> {
|
||||
confy::load("managarr", "config")?
|
||||
};
|
||||
let spinner_disabled = args.disable_spinner;
|
||||
debug!("Managarr loaded using config: {config:?}");
|
||||
config.validate();
|
||||
let reqwest_client = build_network_client(&config);
|
||||
let (sync_network_tx, sync_network_rx) = mpsc::channel(500);
|
||||
|
||||
Reference in New Issue
Block a user