Skip to main content

default_log_dir_from

Function default_log_dir_from 

Source
pub fn default_log_dir_from(
    xdg_data_home: Option<&str>,
    home: Option<&str>,
    appdata: Option<&str>,
    is_windows: bool,
) -> PathBuf
Expand description

Derive bhtune’s default log directory the same way the database path is derived (see default_db_path_from) – under the platform data directory, not next to the compiled binary. Unlike opcda-bridge-gateway’s equivalent (log_dir_from_exe), a cargo installed binary’s own directory (e.g. ~/.cargo/bin/) isn’t a sensible place to write logs, and bhtune already has this exact precedence machinery for the database, so the log directory reuses it rather than inventing a second convention.

  • Windows (is_windows = true): %APPDATA%\bhtune\logs.
  • Elsewhere: $XDG_DATA_HOME/bhtune/logs, falling back to $HOME/.local/share/bhtune/logs.
  • Falls back further to logs in the current directory if none of the above are available, matching default_db_path_from’s own final fallback.