Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug config info #353

Merged
merged 4 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion service/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,32 @@
use std::process::ExitCode;

use indexer_service_rs::service::run;
use tracing::level_filters::LevelFilter;
use tracing::subscriber::set_global_default;
use tracing_subscriber::{EnvFilter, FmtSubscriber};

#[tokio::main]
async fn main() -> ExitCode {
tracing_subscriber::fmt::init();
init_tracing();
if let Err(e) = run().await {
tracing::error!("Indexer service error: {e}");
return ExitCode::from(1);
}
ExitCode::SUCCESS
}

fn init_tracing() {
// Tracing setup
let filter = EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.from_env_lossy();
let subscriber_builder: tracing_subscriber::fmt::SubscriberBuilder<
tracing_subscriber::fmt::format::DefaultFields,
tracing_subscriber::fmt::format::Format,
EnvFilter,
> = FmtSubscriber::builder().with_env_filter(filter);
set_global_default(subscriber_builder.with_ansi(true).pretty().finish()).expect(
"Could not set up global default subscriber for logger, check \
environmental variable `RUST_LOG`",
);
}
9 changes: 5 additions & 4 deletions tap-agent/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
// SPDX-License-Identifier: Apache-2.0

use anyhow::Result;
use clap::Parser;
use indexer_config::{Config as IndexerConfig, ConfigPrefix};
use reqwest::Url;
use std::path::PathBuf;
use std::{collections::HashMap, str::FromStr};
use tracing::error;

use anyhow::Result;
use thegraph_core::{Address, DeploymentId};
use tracing::subscriber::{set_global_default, SetGlobalDefaultError};
use tracing::{error, level_filters::LevelFilter};
use tracing_subscriber::{EnvFilter, FmtSubscriber};

#[derive(Parser)]
Expand Down Expand Up @@ -165,7 +164,9 @@ pub struct Tap {

/// Sets up tracing, allows log level to be set from the environment variables
fn init_tracing(format: String) -> Result<(), SetGlobalDefaultError> {
let filter = EnvFilter::from_default_env();
let filter = EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.from_env_lossy();
let subscriber_builder: tracing_subscriber::fmt::SubscriberBuilder<
tracing_subscriber::fmt::format::DefaultFields,
tracing_subscriber::fmt::format::Format,
Expand Down
Loading