-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
helix-term: add config option for specifying log file #566
Closed
Closed
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a7a4608
helix-term: add config option for specifying log file
dsseng 2ca9c3a
helix-term: show configured logfile in help
dsseng b75416a
restore default variable for readability
dsseng c9e733a
Merge branch 'master' into log-file-config
dsseng 8591706
remove mistakenly added files
dsseng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,12 +35,8 @@ fn setup_logging(logpath: PathBuf, verbosity: u64) -> Result<()> { | |
|
||
#[tokio::main] | ||
async fn main() -> Result<()> { | ||
let cache_dir = helix_core::cache_dir(); | ||
if !cache_dir.exists() { | ||
std::fs::create_dir_all(&cache_dir).ok(); | ||
} | ||
let log_path_default = helix_core::cache_dir().join("helix.log"); | ||
|
||
let logpath = cache_dir.join("helix.log"); | ||
let help = format!( | ||
"\ | ||
{} {} | ||
|
@@ -63,7 +59,7 @@ FLAGS: | |
env!("CARGO_PKG_VERSION"), | ||
env!("CARGO_PKG_AUTHORS"), | ||
env!("CARGO_PKG_DESCRIPTION"), | ||
logpath.display(), | ||
log_path_default.display(), | ||
dsseng marked this conversation as resolved.
Show resolved
Hide resolved
|
||
); | ||
|
||
let args = Args::parse_args().context("could not parse arguments")?; | ||
|
@@ -90,7 +86,17 @@ FLAGS: | |
Err(err) => return Err(Error::new(err)), | ||
}; | ||
|
||
setup_logging(logpath, args.verbosity).context("failed to initialize logging")?; | ||
let log_path = config | ||
.log_file | ||
.clone() | ||
.map(PathBuf::from) | ||
.unwrap_or(log_path_default); | ||
let log_dir = log_path.parent().unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be |
||
|
||
if !log_dir.exists() { | ||
std::fs::create_dir_all(log_dir).ok(); | ||
} | ||
setup_logging(log_path, args.verbosity).context("failed to initialize logging")?; | ||
|
||
// TODO: use the thread local executor to spawn the application task separately from the work pool | ||
let mut app = Application::new(args, config).context("unable to create new application")?; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would call this log-path rather than log file. You can also use
Option<PathBuf>
here to parse straight into aPathBuf
.