mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-06 17:54:20 +01:00
Merge 'Emit ANSI codes only when tracing is outputting to terminal' from Preston Thorpe
Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com> Closes #1289
This commit is contained in:
27
cli/app.rs
27
cli/app.rs
@@ -818,22 +818,27 @@ impl<'a> Limbo<'a> {
|
||||
}
|
||||
|
||||
pub fn init_tracing(&mut self) -> Result<WorkerGuard, std::io::Error> {
|
||||
let (non_blocking, guard) = if let Some(file) = &self.opts.tracing_output {
|
||||
tracing_appender::non_blocking(
|
||||
std::fs::File::options()
|
||||
.append(true)
|
||||
.create(true)
|
||||
.open(file)?,
|
||||
)
|
||||
} else {
|
||||
tracing_appender::non_blocking(std::io::stderr())
|
||||
};
|
||||
let ((non_blocking, guard), should_emit_ansi) =
|
||||
if let Some(file) = &self.opts.tracing_output {
|
||||
(
|
||||
tracing_appender::non_blocking(
|
||||
std::fs::File::options()
|
||||
.append(true)
|
||||
.create(true)
|
||||
.open(file)?,
|
||||
),
|
||||
false,
|
||||
)
|
||||
} else {
|
||||
(tracing_appender::non_blocking(std::io::stderr()), true)
|
||||
};
|
||||
if let Err(e) = tracing_subscriber::registry()
|
||||
.with(
|
||||
tracing_subscriber::fmt::layer()
|
||||
.with_writer(non_blocking)
|
||||
.with_line_number(true)
|
||||
.with_thread_ids(true),
|
||||
.with_thread_ids(true)
|
||||
.with_ansi(should_emit_ansi),
|
||||
)
|
||||
.with(EnvFilter::from_default_env())
|
||||
.try_init()
|
||||
|
||||
Reference in New Issue
Block a user