Skip to content

Commit

Permalink
Enable info log by default (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
slinkydeveloper authored Apr 24, 2023
1 parent ace0f62 commit 8c53a18
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Restate supports the following SDKs:
You can start the runtime via:

```shell
RUST_LOG=info just run --release
just run --release
```

In order to change the log level, configure the [`RUST_LOG` env variable](https://rust-lang-nursery.github.io/rust-cookbook/development_tools/debugging/config_log.html#enable-log-levels-per-module) respectively.
Expand Down
23 changes: 19 additions & 4 deletions src/tracing_instrumentation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use opentelemetry::trace::TraceError;
use pretty::Pretty;
use std::fmt::Display;
use tracing::Level;
use tracing_subscriber::filter::ParseError;
use tracing_subscriber::fmt::time::SystemTime;
use tracing_subscriber::fmt::writer::MakeWriterExt;
use tracing_subscriber::layer::SubscriberExt;
Expand All @@ -13,9 +14,14 @@ use tracing_subscriber::{EnvFilter, Layer};

#[derive(Debug, thiserror::Error)]
#[error("could not initialize tracing {trace_error}")]
pub struct Error {
#[from]
trace_error: TraceError,
pub enum Error {
#[error("could not initialize tracing: {0}")]
Tracing(#[from] TraceError),
#[error(
"cannot parse log configuration {} environment variable: {0}",
EnvFilter::DEFAULT_ENV
)]
LogDirectiveParseError(#[from] ParseError),
}

pub type TracingResult<T> = Result<T, Error>;
Expand Down Expand Up @@ -93,8 +99,17 @@ impl Options {
.boxed(),
};

// Check if we have env variable
let env_filter = if let Ok(var) = std::env::var(EnvFilter::DEFAULT_ENV) {
EnvFilter::builder().parse(var)?
} else {
EnvFilter::new("warn,restate=info")
};

println!("LOG: {}", env_filter);

let layers = tracing_subscriber::registry()
.with(EnvFilter::from_default_env())
.with(env_filter)
.with(fmt_layer);
#[cfg(feature = "console-subscriber")]
let layers = layers.with(console_subscriber::spawn());
Expand Down

0 comments on commit 8c53a18

Please sign in to comment.