Skip to content

Commit 30a6e28

Browse files
committed
scx_loader: log the selected configuration source
get_config_path() checks four locations in a fixed order and the first existing file wins - including a file that parses to an empty configuration, which silently shadows every path after it. Nothing in the logs says which file was selected, or that none was found and the built-in defaults took over. That silence has a sharp edge: with the shipped defaults mirrored in a vendor config file, a shadowed setup is behaviorally indistinguishable from a working one right up until the first divergent setting - say, enabling the power-profiles integration in a file the loader never reads - which then fails as a silent no-op with nothing to grep for. Diagnosing it today means reasoning backwards from scheduler flags to which file could have produced them, and when the candidate files agree, even that is inconclusive. Log one line at startup naming the selected config file, or stating that no file was found and the built-in defaults are in use. The logger is initialized before init_config() runs, so the line lands in the journal, and "which file rules this daemon" becomes the first line of journalctl output instead of an archaeology exercise. The line is deliberately emitted before parsing rather than after: the parse error chain does not carry the file name (neither the io error from read_to_string nor the toml error names the path), so on invalid TOML the last line in the journal before the failure is the one naming the file being parsed. "Selected" is also the honest verb for that placement - a file that fails to parse was chosen but never took effect. get_config_path() returns Err in exactly one case - no candidate path exists - so the fallback message is precisely as categorical as the code. Path::exists() swallows IO errors (an unstattable file counts as absent), but that is the search's own semantics: such a file is skipped by the loader too, so "found" consistently means "visible to the loader". Signed-off-by: Piotr Gorski <lucjan.lucjanov@gmail.com>
1 parent d598921 commit 30a6e28

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

‎crates/scx_loader/src/config.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ pub struct Sched {
4040
/// This function will return an error if a config file is found but fails to be parsed.
4141
pub fn init_config() -> Result<Config> {
4242
if let Ok(config_path) = get_config_path() {
43+
log::info!("using config file {config_path}");
4344
parse_config_file(&config_path)
4445
} else {
46+
log::info!("no config file found, using built-in default configuration");
4547
Ok(get_default_config())
4648
}
4749
}

0 commit comments

Comments
 (0)