From a52c31e48a6bb85165e55fc39cd6a5ee869152df Mon Sep 17 00:00:00 2001 From: Serge Farny Date: Thu, 14 Mar 2024 17:11:08 +0100 Subject: [PATCH] Migrate to tracing instead of log crate --- Cargo.lock | 17 ++++++++--------- Cargo.toml | 2 +- connector/Cargo.toml | 4 ++-- connector/src/account_write_filter.rs | 2 +- connector/src/grpc_plugin_source.rs | 2 +- connector/src/metrics.rs | 2 +- connector/src/snapshot.rs | 2 +- connector/src/websocket_source.rs | 4 ++-- 8 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3298ecf..f0bcd8e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2639,7 +2639,7 @@ dependencies = [ [[package]] name = "mango-feeds-connector" -version = "0.2.1" +version = "0.2.2" dependencies = [ "anyhow", "async-channel", @@ -2649,7 +2649,6 @@ dependencies = [ "itertools", "jsonrpc-core 18.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "jsonrpc-core-client", - "log 0.4.20", "rustls 0.20.9", "serde", "serde_derive", @@ -2659,6 +2658,7 @@ dependencies = [ "solana-rpc", "solana-sdk", "tokio", + "tracing", "warp", "yellowstone-grpc-client", "yellowstone-grpc-proto", @@ -6551,11 +6551,10 @@ checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.37" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "cfg-if 1.0.0", "log 0.4.20", "pin-project-lite", "tracing-attributes", @@ -6564,9 +6563,9 @@ dependencies = [ [[package]] name = "tracing-attributes" -version = "0.1.26" +version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f4f31f56159e98206da9efd823404b79b6ef3143b4a7ab76e67b1751b25a4ab" +checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2 1.0.67", "quote 1.0.33", @@ -6575,9 +6574,9 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.31" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0955b8137a1df6f1a2e9a37d8a6656291ff0297c1a97c24e0d8425fe2312f79a" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" dependencies = [ "once_cell", ] diff --git a/Cargo.toml b/Cargo.toml index 56d86df..c7d0e92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ jsonrpc-core-client = { version = "18.0.0", features = ["ws", "http"] } bs58 = "0.5" base64 = "0.21.0" -log = "0.4" +tracing = "0.1.40" rand = "0.7" anyhow = "1.0" toml = "0.5" diff --git a/connector/Cargo.toml b/connector/Cargo.toml index 5fc9d18..79e1656 100644 --- a/connector/Cargo.toml +++ b/connector/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mango-feeds-connector" -version = "0.2.1" +version = "0.2.2" authors = ["Christian Kamm "] edition = "2021" license = "AGPL-3.0-or-later" @@ -27,7 +27,7 @@ rustls = { workspace = true } serde = { workspace = true } serde_derive = { workspace = true } -log = { workspace = true } +tracing = { workspace = true } anyhow = { workspace = true } itertools = { workspace = true } diff --git a/connector/src/account_write_filter.rs b/connector/src/account_write_filter.rs index 3aed358..0c466af 100644 --- a/connector/src/account_write_filter.rs +++ b/connector/src/account_write_filter.rs @@ -5,13 +5,13 @@ use crate::{ }; use async_trait::async_trait; -use log::*; use solana_sdk::{account::WritableAccount, pubkey::Pubkey, stake_history::Epoch}; use std::{ collections::{BTreeSet, HashMap}, sync::Arc, time::{Duration, Instant}, }; +use tracing::*; #[async_trait] pub trait AccountWriteSink { diff --git a/connector/src/grpc_plugin_source.rs b/connector/src/grpc_plugin_source.rs index 26a5165..01af556 100644 --- a/connector/src/grpc_plugin_source.rs +++ b/connector/src/grpc_plugin_source.rs @@ -11,10 +11,10 @@ use yellowstone_grpc_proto::tonic::{ Request, }; -use log::*; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; use std::{collections::HashMap, env, str::FromStr, time::Duration}; +use tracing::*; use yellowstone_grpc_proto::geyser::{ subscribe_request_filter_accounts_filter, subscribe_request_filter_accounts_filter_memcmp, SubscribeRequestFilterAccountsFilter, SubscribeRequestFilterAccountsFilterMemcmp, diff --git a/connector/src/metrics.rs b/connector/src/metrics.rs index 2a90a77..9137404 100644 --- a/connector/src/metrics.rs +++ b/connector/src/metrics.rs @@ -1,10 +1,10 @@ use { crate::MetricsConfig, - log::*, std::collections::HashMap, std::fmt, std::sync::{atomic, Arc, Mutex, RwLock}, tokio::time, + tracing::*, warp::{Filter, Rejection, Reply}, }; diff --git a/connector/src/snapshot.rs b/connector/src/snapshot.rs index 9d21f13..a9e0307 100644 --- a/connector/src/snapshot.rs +++ b/connector/src/snapshot.rs @@ -1,5 +1,4 @@ use jsonrpc_core_client::transports::http; -use log::*; use solana_account_decoder::{UiAccount, UiAccountEncoding}; use solana_client::{ rpc_config::{RpcAccountInfoConfig, RpcProgramAccountsConfig}, @@ -8,6 +7,7 @@ use solana_client::{ use solana_rpc::rpc::rpc_accounts::AccountsDataClient; use solana_rpc::rpc::rpc_accounts_scan::AccountsScanClient; use solana_sdk::{commitment_config::CommitmentConfig, slot_history::Slot}; +use tracing::*; use crate::{AnyhowWrap, FeedFilterType}; diff --git a/connector/src/websocket_source.rs b/connector/src/websocket_source.rs index a8abc0b..6044c7f 100644 --- a/connector/src/websocket_source.rs +++ b/connector/src/websocket_source.rs @@ -12,7 +12,6 @@ use solana_sdk::{ }; use anyhow::Context; -use log::*; use std::ops::Sub; use std::{ str::FromStr, @@ -20,6 +19,7 @@ use std::{ time::{Duration, Instant}, }; use tokio::time::timeout; +use tracing::*; use crate::snapshot::{ get_snapshot_gma, get_snapshot_gpa, SnapshotMultipleAccounts, SnapshotProgramAccounts, @@ -363,7 +363,7 @@ pub async fn process_events( .expect("send success"); } WebsocketMessage::SnapshotUpdate((slot, accounts)) => { - trace!("snapshot update {slot}"); + debug!("snapshot update {slot}"); let mut to_send = vec![]; for (pubkey, account) in accounts { if let Some(account) = account {