{"record":{"id":"dbbc100ea8f36e9b","repo":"nautechsystems/nautilus_trader","slug":"invalid-log-level-v","errorCode":null,"errorMessage":"Invalid log level: {v}","messagePattern":"Invalid log level: (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/common/src/logging/config.rs","lineNumber":296,"sourceCode":"    /// # Errors\n    ///\n    /// Returns an error if the variable is unset or contains invalid syntax.\n    pub fn from_env() -> anyhow::Result<Self> {\n        let spec = env::var(\"NAUTILUS_LOG\")?;\n        Self::from_spec(&spec)\n    }\n}\n\n/// Parses a boolean value from a string.\n///\n/// Returns `true` unless the value is explicitly \"false\", \"0\", or \"no\" (case-insensitive).\nfn parse_bool_value(v: &str) -> bool {\n    !matches!(v.to_lowercase().as_str(), \"false\" | \"0\" | \"no\")\n}\n\n/// Parses a log level from a string.\nfn parse_level(v: &str) -> anyhow::Result<LevelFilter> {\n    LevelFilter::from_str(v).map_err(|_| anyhow::anyhow!(\"Invalid log level: {v}\"))\n}\n\n#[cfg(test)]\nmod tests {\n    use rstest::rstest;\n\n    use super::*;\n    use crate::config::ConfigError;\n\n    #[rstest]\n    fn test_zero_rotation_max_file_size_rejected() {\n        let file_config = FileWriterConfig::new(None, None, None, Some((0, 5)));\n        let result = LoggerConfig::builder().file_config(file_config).build();\n        assert!(\n            matches!(result, Err(ConfigError::Range { field, .. }) if field == \"file_config.file_rotate.max_file_size\")\n        );\n    }\n","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/common/src/logging/config.rs#L278-L314","documentation":"`parse_level` (crates/common/src/logging/config.rs) converts a spec string into a tracing LevelFilter using FromStr, and maps any parse failure to this error. It exists so bad log-level strings in env vars or config specs surface a clear message naming the offending value.","triggerScenarios":"Passing a level string that is not one of TRACE/DEBUG/INFO/WARN/ERROR/OFF (case accepted by tracing, plus lowercase variants) to the logging spec — e.g. NAUTILUS_LOG levels segment set to \"verbose\", \"warning\", \"LOG_INFO\", \"\" or \"info;\" with stray punctuation.","commonSituations":"Copying Python logging level names (\"WARNING\", \"CRITICAL\") or syslog names into the spec; typos like \"DEBG\"; env var containing whitespace or quotes from shell escaping; a component name accidentally parsed as a level in the spec string.","solutions":["Use one of the accepted levels: trace, debug, info, warn, error, off (case-insensitive).","Map Python-style names before passing: WARNING->WARN, CRITICAL->ERROR.","Trim whitespace/quotes from the env/config value and check spec separators (';' component=LEVEL pairs).","Log or echo the failing spec value and validate at startup before launching the node."],"exampleFix":"// before\nNAUTILUS_LOG=\"warning\"  // parse_level fails\n// after\nNAUTILUS_LOG=\"warn\"     // or map: let level = match s {\"WARNING\"=>\"WARN\", s=>s};","handlingStrategy":"validation","validationCode":"// Rust: validate level before building the config\nconst LEVELS: [&str; 6] = [\"trace\",\"debug\",\"info\",\"warn\",\"error\",\"off\"];\nassert!(LEVELS.contains(&level.to_lowercase().as_str()), \"invalid level {level}\");","typeGuard":"fn parse_level_or(v: &str, default: LevelFilter) -> LevelFilter {\n    LevelFilter::from_str(v).unwrap_or(default)\n}","tryCatchPattern":"match parse_level(spec) {\n    Ok(l) => l,\n    Err(e) => { eprintln!(\"fix NAUTILUS_LOG: {e}; use trace|debug|info|warn|error|off\"); std::process::exit(2); }\n}","preventionTips":["Memorize the accepted set: trace, debug, info, warn, error, off.","Translate Python/logging-framework level names before passing them in.","Validate log specs at startup with a clear CLI check, before node launch.","Avoid quotes/whitespace leaking into env values from shell wrappers."],"tags":["rust","logging","configuration","parsing"],"backgroundTag":"invalid-config-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}