Skip to content

Commit

Permalink
test(federation-cli): enable log printing from apollo-federation-cli …
Browse files Browse the repository at this point in the history
…(backport #6717) (#6755)

Co-authored-by: Duckki Oe <duckki.oe@apollographql.com>
  • Loading branch information
mergify[bot] and duckki authored Feb 11, 2025
1 parent 227052b commit a815e3c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ dependencies = [
"insta",
"serde",
"serde_json",
"tracing-subscriber",
]

[[package]]
Expand Down
1 change: 1 addition & 0 deletions apollo-federation/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ edition = "2021"
apollo-compiler.workspace = true
apollo-federation = { path = ".." }
clap = { version = "4.5.1", features = ["derive"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }

[dev-dependencies]
insta = { version = "1.38.0", features = ["json", "redactions"] }
Expand Down
16 changes: 15 additions & 1 deletion apollo-federation/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ use apollo_federation::query_graph;
use apollo_federation::query_plan::query_planner::QueryPlanner;
use apollo_federation::query_plan::query_planner::QueryPlannerConfig;
use apollo_federation::subgraph;
use bench::BenchOutput;
use clap::Parser;
use tracing_subscriber::prelude::*;

mod bench;
use bench::run_bench;
use bench::BenchOutput;

#[derive(Parser)]
struct QueryPlannerArgs {
Expand Down Expand Up @@ -123,7 +124,20 @@ impl From<QueryPlannerArgs> for QueryPlannerConfig {
}
}

/// Set up the tracing subscriber
fn init_tracing() {
let fmt_layer = tracing_subscriber::fmt::layer()
.without_time()
.with_target(false);
let filter_layer = tracing_subscriber::EnvFilter::from_default_env();
tracing_subscriber::registry()
.with(fmt_layer)
.with(filter_layer)
.init();
}

fn main() -> ExitCode {
init_tracing();
let args = Args::parse();
let result = match args.command {
Command::Api {
Expand Down

0 comments on commit a815e3c

Please sign in to comment.