logger: create the log in the home directory

Prevent an issue on windows where the application could
not start because the log was created in the app folder.
This commit is contained in:
Stéphane Cerveau 2022-11-17 13:02:02 +01:00
parent 378d867520
commit d1ccea7ea8
4 changed files with 6 additions and 4 deletions

4
Cargo.lock generated
View file

@ -730,9 +730,9 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
[[package]]
name = "libc"
version = "0.2.103"
version = "0.2.137"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8f7255a17a627354f321ef0055d63b898c6fb27eff628af4d1b66b7331edf6"
checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
[[package]]
name = "linked-hash-map"

View file

@ -983,6 +983,7 @@ impl GPSApp {
fn load_graph(&self, filename: &str) -> anyhow::Result<()> {
let graph_view = self.graphview.borrow();
GPS_INFO!("Open graph file {}", filename);
let mut file = File::open(filename)?;
let mut buffer = Vec::new();
file.read_to_end(&mut buffer).expect("buffer overflow");

View file

@ -125,7 +125,7 @@ pub fn init_logger(sender: Sender<String>, log_file: &str) {
WriteLogger::new(
translate_to_simple_logger(LogLevel::Trace),
Config::default(),
File::create(log_file).unwrap(),
File::create(log_file).unwrap_or_else(|_| panic!("Unable to create log {}", log_file)),
),
WriteLogger::new(
translate_to_simple_logger(LogLevel::Debug),

View file

@ -64,7 +64,8 @@ impl Settings {
}
pub fn default_log_file_path() -> PathBuf {
let mut path = PathBuf::new();
let mut path = glib::user_config_dir();
path.push(config::APP_ID);
path.push("gstpipelinestudio.log");
path
}