Skip to content

Commit

Permalink
feat: Write coordinator logs in GCP compatible format (#984)
Browse files Browse the repository at this point in the history
  • Loading branch information
morgsmccauley authored Aug 7, 2024
1 parent 7e2b273 commit 7e7f6c0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions coordinator/Cargo.lock

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

1 change: 1 addition & 0 deletions coordinator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ tokio = "1.28"
tonic = "0.10.2"
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
tracing-stackdriver = "0.10.0"
serde = "1.0.195"
serde_json = "1.0.108"

Expand Down
14 changes: 10 additions & 4 deletions coordinator/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ async fn sleep(duration: Duration) -> anyhow::Result<()> {

#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::registry()
.with(tracing_subscriber::fmt::layer())
.with(tracing_subscriber::EnvFilter::from_default_env())
.init();
let subscriber =
tracing_subscriber::registry().with(tracing_subscriber::EnvFilter::from_default_env());

if std::env::var("GCP_LOGGING_ENABLED").is_ok() {
subscriber.with(tracing_stackdriver::layer()).init();
} else {
subscriber
.with(tracing_subscriber::fmt::layer().compact())
.init();
}

let rpc_url = std::env::var("RPC_URL").expect("RPC_URL is not set");
let registry_contract_id = std::env::var("REGISTRY_CONTRACT_ID")
Expand Down

0 comments on commit 7e7f6c0

Please sign in to comment.