diff --git a/crates/turborepo-lib/src/run/cache.rs b/crates/turborepo-lib/src/run/cache.rs index b70abdd6e48c3..50767b758b263 100644 --- a/crates/turborepo-lib/src/run/cache.rs +++ b/crates/turborepo-lib/src/run/cache.rs @@ -196,18 +196,15 @@ impl TaskCache { pub fn output_writer(&self, writer: W) -> Result, Error> { let mut log_writer = LogWriter::default(); - if self.caching_disabled || self.run_cache.writes_disabled { - log_writer.with_writer(writer); - return Ok(log_writer); + if !self.caching_disabled && !self.run_cache.writes_disabled { + log_writer.with_log_file(&self.log_file_path)?; } - log_writer.with_log_file(&self.log_file_path)?; - - if !matches!( - self.task_output_logs, - OutputLogsMode::None | OutputLogsMode::HashOnly | OutputLogsMode::ErrorsOnly - ) { - log_writer.with_writer(writer); + match self.task_output_logs { + OutputLogsMode::None | OutputLogsMode::HashOnly | OutputLogsMode::ErrorsOnly => {} + OutputLogsMode::Full | OutputLogsMode::NewOnly => { + log_writer.with_writer(writer); + } } Ok(log_writer) diff --git a/crates/turborepo-ui/src/logs.rs b/crates/turborepo-ui/src/logs.rs index be89d6836fbf8..0c4cb5ae339ce 100644 --- a/crates/turborepo-ui/src/logs.rs +++ b/crates/turborepo-ui/src/logs.rs @@ -58,9 +58,14 @@ impl Write for LogWriter { (Some(log_file), None) => log_file.write(buf), (None, Some(prefixed_writer)) => prefixed_writer.write(buf), (None, None) => { - // Should this be an error or even a panic? - debug!("no log file or prefixed writer"); - Ok(0) + debug!( + "No log file or prefixed writer to write to. This should only happen when \ + both caching is disabled and output logs are set to none." + ); + + // Returning the buffer's length so callers don't think this is a failure to + // create the buffer + Ok(buf.len()) } } } diff --git a/turborepo-tests/integration/tests/run-logging/no-cache-and-no-output-logs.t b/turborepo-tests/integration/tests/run-logging/no-cache-and-no-output-logs.t new file mode 100644 index 0000000000000..1c495a40c5544 --- /dev/null +++ b/turborepo-tests/integration/tests/run-logging/no-cache-and-no-output-logs.t @@ -0,0 +1,13 @@ +Setup + $ . ${TESTDIR}/../../../helpers/setup_integration_test.sh run_logging + + $ ${TURBO} run build --cache=local:,remote: --output-logs=none + WARNING no caches are enabled + \xe2\x80\xa2 Packages in scope: app-a (esc) + \xe2\x80\xa2 Running build in 1 packages (esc) + \xe2\x80\xa2 Remote caching disabled (esc) + + Tasks: 1 successful, 1 total + Cached: 0 cached, 1 total + Time:\s*[\.0-9]+m?s (re) +