Skip to content
This repository has been archived by the owner on Nov 23, 2024. It is now read-only.

Commit

Permalink
Fix logs not being flushed
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Mackie authored and Jordan Mackie committed Mar 2, 2023
1 parent ccc5541 commit a09e542
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
14 changes: 4 additions & 10 deletions crates/ditto-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ async fn try_main() -> Result<()> {
let mut cmd = command(&version_short, &version_long);
let matches = cmd.get_matches_mut();

let mut guards = Vec::new();
let _flame_layer_guard;
let flame_layer = if let Ok(trace_dir) = std::env::var("DITTO_TRACE_DIR") {
let trace_dir = std::path::PathBuf::from(trace_dir);
if !trace_dir.exists() {
Expand All @@ -131,15 +131,13 @@ async fn try_main() -> Result<()> {
let mut trace_file = trace_dir;
trace_file.push(calculate_hash(&args).to_string());
let (flame_layer, guard) = FlameLayer::with_file(trace_file).into_diagnostic()?;
guards.push(
// NOTE: using `Result` as a quick and easy `Either`
Err(guard),
);
_flame_layer_guard = guard;
Some(flame_layer.with_file_and_line(false))
} else {
None
};

let _fmt_layer_guard;
let fmt_layer = if let Ok(log_file) = std::env::var("DITTO_LOG_FILE") {
let log_file = std::path::PathBuf::from(log_file);
let log_file = if !running_in_ninja {
Expand All @@ -162,11 +160,7 @@ async fn try_main() -> Result<()> {
.into_diagnostic()?
};
let (non_blocking, guard) = tracing_appender::non_blocking(LogFile(log_file));
guards.push(
// NOTE: using `Result` as a quick and easy `Either`
Ok(guard),
);

_fmt_layer_guard = guard;
let mut fmt_layer = tracing_subscriber::fmt::Layer::new()
.json()
.with_writer(non_blocking);
Expand Down
1 change: 0 additions & 1 deletion crates/ditto-cli/src/make.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,6 @@ async fn run_once(
// Crash if we fail to release the lock otherwise things are likely to misbehave...
.expect("Error releasing lock on build directory");

// FIXME: this isn't always logged - do we need to await something from tracing_subscriber?
debug!("make ran in {}ms", now.elapsed().as_millis());

result
Expand Down

0 comments on commit a09e542

Please sign in to comment.