Skip to content

Commit

Permalink
Merge pull request #50 from wojciechkepka/config
Browse files Browse the repository at this point in the history
Use config_dir for logging, create config_dir
  • Loading branch information
archseer committed Jun 2, 2021
2 parents b51111a + e88383d commit 0a6672c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions helix-term/src/main.rs
Expand Up @@ -8,6 +8,8 @@ mod ui;

use application::Application;

use helix_core::config_dir;

use std::path::PathBuf;

use anyhow::{Context, Result};
Expand All @@ -27,8 +29,6 @@ fn setup_logging(verbosity: u64) -> Result<()> {
_3_or_more => base_config.level(log::LevelFilter::Trace),
};

let home = dirs_next::home_dir().context("can't find the home directory")?;

// Separate file config so we can include year, month and day in file logs
let file_config = fern::Dispatch::new()
.format(|out, message, record| {
Expand All @@ -40,7 +40,7 @@ fn setup_logging(verbosity: u64) -> Result<()> {
message
))
})
.chain(fern::log_file(home.join("helix.log"))?);
.chain(fern::log_file(config_dir().join("helix.log"))?);

base_config.chain(file_config).apply()?;

Expand Down Expand Up @@ -89,14 +89,19 @@ FLAGS:
verbosity = 1;
}

let conf_dir = config_dir();

if !conf_dir.exists() {
std::fs::create_dir(&conf_dir);
}

setup_logging(verbosity).context("failed to initialize logging")?;

let args = Args {
files: pargs.finish().into_iter().map(|arg| arg.into()).collect(),
};

// initialize language registry
use helix_core::config_dir;
use helix_core::syntax::{Loader, LOADER};

// load $HOME/.config/helix/languages.toml, fallback to default config
Expand Down

0 comments on commit 0a6672c

Please sign in to comment.