on master help sign in
Use config_dir for logging, create config_dir
commite88383d990cc8f5092e8513c91a17530dab0c444 authorWojciech Kępka <wojtek.kepka@protonmail.com> dateWed 2 Jun 2021, 12:25 (5 years ago) parentf4560cb
1 file changed+9−4
helix-term/src/main.rs+9−4
helix-term/src/main.rs+9−4
@@ -8,6 +8,8 @@ mod ui;
88
99use application::Application;
1010
11+use helix_core::config_dir;
12+
1113use std::path::PathBuf;
1214
1315use anyhow::{Context, Result};
@@ -27,8 +29,6 @@ fn setup_logging(verbosity: u64) -> Result<()> {
2729 _3_or_more => base_config.level(log::LevelFilter::Trace),
2830 };
2931
30− let home = dirs_next::home_dir().context("can't find the home directory")?;
31−
3232 // Separate file config so we can include year, month and day in file logs
3333 let file_config = fern::Dispatch::new()
3434 .format(|out, message, record| {
@@ -40,7 +40,7 @@ fn setup_logging(verbosity: u64) -> Result<()> {
4040 message
4141 ))
4242 })
43− .chain(fern::log_file(home.join("helix.log"))?);
43+ .chain(fern::log_file(config_dir().join("helix.log"))?);
4444
4545 base_config.chain(file_config).apply()?;
4646
@@ -89,6 +89,12 @@ FLAGS:
8989 verbosity = 1;
9090 }
9191
92+ let conf_dir = config_dir();
93+
94+ if !conf_dir.exists() {
95+ std::fs::create_dir(&conf_dir);
96+ }
97+
9298 setup_logging(verbosity).context("failed to initialize logging")?;
9399
94100 let args = Args {
@@ -96,7 +102,6 @@ FLAGS:
96102 };
97103
98104 // initialize language registry
99− use helix_core::config_dir;
100105 use helix_core::syntax::{Loader, LOADER};
101106
102107 // load $HOME/.config/helix/languages.toml, fallback to default config