File tree Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Expand file tree Collapse file tree 2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 44use std:: process:: ExitCode ;
55
66use indexer_service_rs:: service:: run;
7+ use tracing:: level_filters:: LevelFilter ;
8+ use tracing:: subscriber:: set_global_default;
9+ use tracing_subscriber:: { EnvFilter , FmtSubscriber } ;
710
811#[ tokio:: main]
912async fn main ( ) -> ExitCode {
10- tracing_subscriber :: fmt :: init ( ) ;
13+ init_tracing ( ) ;
1114 if let Err ( e) = run ( ) . await {
1215 tracing:: error!( "Indexer service error: {e}" ) ;
1316 return ExitCode :: from ( 1 ) ;
1417 }
1518 ExitCode :: SUCCESS
1619}
20+
21+ fn init_tracing ( ) {
22+ // Tracing setup
23+ let filter = EnvFilter :: builder ( )
24+ . with_default_directive ( LevelFilter :: INFO . into ( ) )
25+ . from_env_lossy ( ) ;
26+ let subscriber_builder: tracing_subscriber:: fmt:: SubscriberBuilder <
27+ tracing_subscriber:: fmt:: format:: DefaultFields ,
28+ tracing_subscriber:: fmt:: format:: Format ,
29+ EnvFilter ,
30+ > = FmtSubscriber :: builder ( ) . with_env_filter ( filter) ;
31+ set_global_default ( subscriber_builder. with_ansi ( true ) . pretty ( ) . finish ( ) ) . expect (
32+ "Could not set up global default subscriber for logger, check \
33+ environmental variable `RUST_LOG`",
34+ ) ;
35+ }
Original file line number Diff line number Diff line change 11// Copyright 2023-, Edge & Node, GraphOps, and Semiotic Labs.
22// SPDX-License-Identifier: Apache-2.0
33
4+ use anyhow:: Result ;
45use clap:: Parser ;
56use indexer_config:: { Config as IndexerConfig , ConfigPrefix } ;
67use reqwest:: Url ;
78use std:: path:: PathBuf ;
89use std:: { collections:: HashMap , str:: FromStr } ;
9- use tracing:: error;
10-
11- use anyhow:: Result ;
1210use thegraph_core:: { Address , DeploymentId } ;
1311use tracing:: subscriber:: { set_global_default, SetGlobalDefaultError } ;
12+ use tracing:: { error, level_filters:: LevelFilter } ;
1413use tracing_subscriber:: { EnvFilter , FmtSubscriber } ;
1514
1615#[ derive( Parser ) ]
@@ -165,7 +164,9 @@ pub struct Tap {
165164
166165/// Sets up tracing, allows log level to be set from the environment variables
167166fn init_tracing ( format : String ) -> Result < ( ) , SetGlobalDefaultError > {
168- let filter = EnvFilter :: from_default_env ( ) ;
167+ let filter = EnvFilter :: builder ( )
168+ . with_default_directive ( LevelFilter :: INFO . into ( ) )
169+ . from_env_lossy ( ) ;
169170 let subscriber_builder: tracing_subscriber:: fmt:: SubscriberBuilder <
170171 tracing_subscriber:: fmt:: format:: DefaultFields ,
171172 tracing_subscriber:: fmt:: format:: Format ,
You can’t perform that action at this time.
0 commit comments