-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Write logs to filesystem * ansiterm * clean up * update tests * update more tests
- Loading branch information
Showing
14 changed files
with
339 additions
and
192 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
use crate::path::{fuelup_log_dir, FUELUP_DIR, FUELUP_HOME}; | ||
use std::env; | ||
use tracing::{debug, level_filters::LevelFilter}; | ||
use tracing_appender::non_blocking::WorkerGuard; | ||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, Layer}; | ||
|
||
pub fn log_command() { | ||
debug!( | ||
"Command: {}", | ||
env::args().collect::<Vec<String>>().join(" ") | ||
); | ||
} | ||
|
||
pub fn log_environment() { | ||
if let Some(val) = env::var_os("PATH") { | ||
if let Some(fuelup_path) = | ||
env::split_paths(&val).find(|p| p.to_string_lossy().contains(FUELUP_DIR)) | ||
{ | ||
debug!("PATH includes {}", fuelup_path.to_string_lossy()); | ||
} else { | ||
debug!("PATH does not include {}", FUELUP_DIR); | ||
} | ||
} | ||
if let Some(val) = env::var_os(FUELUP_HOME) { | ||
debug!("FUELUP_HOME: {}", val.to_string_lossy()); | ||
} else { | ||
debug!("FUELUP_HOME is not set"); | ||
} | ||
} | ||
|
||
pub fn init_tracing() -> WorkerGuard { | ||
let file_appender = tracing_appender::rolling::hourly(fuelup_log_dir(), "fuelup.log"); | ||
let (file_writer, guard) = tracing_appender::non_blocking(file_appender); | ||
|
||
tracing_subscriber::Registry::default() | ||
.with( | ||
tracing_subscriber::fmt::Layer::default() | ||
.with_writer(file_writer) | ||
.log_internal_errors(false) | ||
.with_target(false) | ||
.with_filter(LevelFilter::DEBUG), | ||
) | ||
.with( | ||
tracing_subscriber::fmt::Layer::default() | ||
.with_writer(std::io::stdout) | ||
.without_time() | ||
.with_level(false) | ||
.with_target(false) | ||
.with_filter(LevelFilter::INFO), | ||
) | ||
.init(); | ||
|
||
guard | ||
} |
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
Oops, something went wrong.