Explorar el Código

util/cli: create ~/.local directory for log file if it's not exist

ghassmo hace 4 años
padre
commit
75c21bb59c
Se han modificado 1 ficheros con 4 adiciones y 1 borrados
  1. 4 1
      src/util/cli.rs

+ 4 - 1
src/util/cli.rs

@@ -167,7 +167,10 @@ macro_rules! async_daemonize {
 
 
             let log_file_path = match std::env::var("DARKFI_LOG") {
             let log_file_path = match std::env::var("DARKFI_LOG") {
                 Ok(p) => p,
                 Ok(p) => p,
-                Err(_) => "~/.local/darkfi.log".into(),
+                Err(_) => {
+                    std::fs::create_dir_all(expand_path("~/.local")?)?;
+                    "~/.local/darkfi.log".into()
+                }
             };
             };
 
 
             let log_file_path = expand_path(&log_file_path)?;
             let log_file_path = expand_path(&log_file_path)?;