Skip to content

Commit

Permalink
editoast: change from 'env_logger' to 'tracing-subscriber'
Browse files Browse the repository at this point in the history
With the objective to instrument `editoast` with OpenTelemetry,
let's use `tracing-subscriber` which will allow to configure a
stdout logger with an Opentelemetry emitter.
  • Loading branch information
woshilapin committed Feb 15, 2024
1 parent 0b7e794 commit e219c0d
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 55 deletions.
135 changes: 83 additions & 52 deletions editoast/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion editoast/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ actix-files = "0.6.5"
actix-web = "4.4.1"
actix-http = "3.5.1"
actix-cors = "0.7.0"
env_logger = "0.10.1"
tracing-subscriber = { version = "0.3.18", features = [ "env-filter" ] }
log = "0.4.20"
redis = { version = "0.24.0", features = [
"tokio-comp",
Expand Down
14 changes: 12 additions & 2 deletions editoast/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,20 @@ use views::search::{SearchConfig, SearchConfigFinder, SearchConfigStore};

type DbPool = Pool<PgConnection>;

fn init_tracing() {
tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::builder()
// Set the default log level to 'info'
.with_default_directive(tracing_subscriber::filter::LevelFilter::INFO.into())
.from_env_lossy(),
)
.with(tracing_subscriber::fmt::layer().pretty())
}

#[actix_web::main]
async fn main() {
// Set the default log level to 'info'
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
init_tracing();

match run().await {
Ok(_) => (),
Expand Down

0 comments on commit e219c0d

Please sign in to comment.