Skip to content

Commit c5bbc5c

Browse files
committed
Add command line parameter to specify log file
I had the logs of my debug helix mixed in with the logs from the production helix. Add a `--log` command line argument to redirect any logs to other files, making my debugging easier :-)
1 parent 0361217 commit c5bbc5c

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

helix-term/src/args.rs

+5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub struct Args {
1414
pub build_grammars: bool,
1515
pub split: Option<Layout>,
1616
pub verbosity: u64,
17+
pub log_file: Option<PathBuf>,
1718
pub config_file: Option<PathBuf>,
1819
pub files: Vec<(PathBuf, Position)>,
1920
}
@@ -48,6 +49,10 @@ impl Args {
4849
Some(path) => args.config_file = Some(path.into()),
4950
None => anyhow::bail!("--config must specify a path to read"),
5051
},
52+
"--log" => match argv.next().as_deref() {
53+
Some(path) => args.log_file = Some(path.into()),
54+
None => anyhow::bail!("--log must specify a path to write"),
55+
},
5156
arg if arg.starts_with("--") => {
5257
anyhow::bail!("unexpected double dash argument: {}", arg)
5358
}

helix-term/src/main.rs

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ FLAGS:
6767
-g, --grammar {{fetch|build}} Fetches or builds tree-sitter grammars listed in languages.toml
6868
-c, --config <file> Specifies a file to use for configuration
6969
-v Increases logging verbosity each use for up to 3 times
70+
--logfile Specifies a file to use for logging
7071
(default file: {})
7172
-V, --version Prints version information
7273
--vsplit Splits all given files vertically into different windows
@@ -114,6 +115,7 @@ FLAGS:
114115
return Ok(0);
115116
}
116117

118+
let logpath = args.log_file.as_ref().cloned().unwrap_or(logpath);
117119
setup_logging(logpath, args.verbosity).context("failed to initialize logging")?;
118120

119121
let config_dir = helix_loader::config_dir();

0 commit comments

Comments
 (0)