Skip to content

Commit

Permalink
fix: log to stderr, only color if no tty
Browse files Browse the repository at this point in the history
Closes #87.
  • Loading branch information
conorsch committed Jun 5, 2024
1 parent 515c8d6 commit 3d75d77
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl EventHandler for Handler {
Ok(m) => m,
Err(e) => {
// We can't return an error, but we also can't proceed, so log the error
// and bare-return to bail out.
// and early-return to bail out.
tracing::error!(%e, "failed to get message info for message");
return;
}
Expand Down
6 changes: 5 additions & 1 deletion src/tracing.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::io::IsTerminal as _;
use tracing_subscriber::{prelude::*, EnvFilter};

/// Initializes a tracing subscriber.
pub(crate) fn init_subscriber() -> anyhow::Result<()> {
let fmt_layer = tracing_subscriber::fmt::layer().with_target(true);
let fmt_layer = tracing_subscriber::fmt::layer()
.with_target(true)
.with_ansi(std::io::stderr().is_terminal())
.with_writer(std::io::stderr);
let filter_layer = EnvFilter::try_from_default_env()
.or_else(|_| EnvFilter::try_new("info"))?
// Force disabling of r1cs log messages, otherwise the `ark-groth16` crate
Expand Down

0 comments on commit 3d75d77

Please sign in to comment.