|
|
@@ -107,16 +107,19 @@ async fn init() -> Result<()> {
|
|
|
#[tracing::instrument]
|
|
|
async fn main() -> Result<()> {
|
|
|
// Initialize a Tracing Subscriber
|
|
|
- tracing::subscriber::set_global_default(
|
|
|
- tracing_subscriber::fmt()
|
|
|
- .compact()
|
|
|
- .with_file(false)
|
|
|
- .with_line_number(true)
|
|
|
- .with_thread_ids(true)
|
|
|
- .with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
|
|
|
- .with_ansi(std::io::stderr().is_terminal())
|
|
|
- .finish(),
|
|
|
- )?;
|
|
|
+ let fmt_builder = tracing_subscriber::fmt()
|
|
|
+ .with_file(false)
|
|
|
+ .with_line_number(true)
|
|
|
+ .with_thread_ids(true)
|
|
|
+ .with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
|
|
|
+ .with_ansi(std::io::stderr().is_terminal());
|
|
|
+
|
|
|
+ // Use the compact formatter if we're in a terminal, otherwise use the JSON formatter.
|
|
|
+ if std::io::stderr().is_terminal() {
|
|
|
+ tracing::subscriber::set_global_default(fmt_builder.compact().finish())?;
|
|
|
+ } else {
|
|
|
+ tracing::subscriber::set_global_default(fmt_builder.json().finish())?;
|
|
|
+ }
|
|
|
|
|
|
// Launch the application. If it fails, print the full backtrace and exit. RUST_BACKTRACE
|
|
|
// should be set to 1 for this otherwise it will only print the top-level error.
|