Skip to content

Commit

Permalink
Replace log with tracing (near#6329)
Browse files Browse the repository at this point in the history
Majority of our code bases uses tracing for logging with only handful
of places remaining which use log instead.  For consistency convert
everything to tracing.

Fixes: near#4346
  • Loading branch information
mina86 authored Feb 22, 2022
1 parent 43198d6 commit ecc1756
Show file tree
Hide file tree
Showing 40 changed files with 71 additions and 84 deletions.
45 changes: 12 additions & 33 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion chain/chain-primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ description = "This crate hosts NEAR chain-related error types"
chrono = { version = "0.4.4", features = ["serde"] }
failure = "0.1"
failure_derive = "0.1"
log = "0.4"
tracing = "0.1.13"
thiserror = "1.0"

near-primitives = { path = "../../core/primitives" }
Expand Down
2 changes: 1 addition & 1 deletion chain/chain-primitives/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use chrono::DateTime;
use near_primitives::time::Utc;

use failure::{Backtrace, Context, Fail};
use log::error;
use tracing::error;

use near_primitives::block::BlockValidityError;
use near_primitives::challenge::{ChunkProofs, ChunkState};
Expand Down
2 changes: 1 addition & 1 deletion chain/chunks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ actix = "=0.11.0-beta.2"
futures = "0.3"
rand = "0.7"
chrono = "0.4.6"
log = "0.4"
tracing = "0.1.13"
borsh = "0.9"
lru = "0.7.2"
reed-solomon-erasure = "4"
Expand Down
2 changes: 1 addition & 1 deletion chain/chunks/src/chunk_cache.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::collections::{HashMap, HashSet};

use log::warn;
use near_primitives::hash::CryptoHash;
use near_primitives::sharding::{
ChunkHash, PartialEncodedChunkPart, PartialEncodedChunkV2, ReceiptProof, ShardChunkHeader,
};
use near_primitives::types::{BlockHeight, BlockHeightDelta, ShardId};
use std::collections::hash_map::Entry::Occupied;
use tracing::warn;

// This file implements EncodedChunksCache, which provides three main functionalities:
// 1) It stores a map from a chunk hash to all the parts and receipts received so far for the chunk.
Expand Down
2 changes: 1 addition & 1 deletion chain/chunks/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ use std::time::{Duration, Instant};

use borsh::BorshSerialize;
use chrono::DateTime;
use log::{debug, error, warn};
use near_primitives::time::Utc;
use rand::seq::IteratorRandom;
use rand::seq::SliceRandom;
use tracing::{debug, error, warn};

use near_chain::validate::validate_chunk_proofs;
use near_chain::{
Expand Down
2 changes: 1 addition & 1 deletion chain/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ actix = "=0.11.0-beta.2"
actix-rt = "2"
futures = "0.3"
chrono = { version = "0.4.4", features = ["serde"] }
log = "0.4"
tracing = "0.1.13"
rand = "0.7"
serde_json = "1"
# Temporary workaround, fix with rust toolchain update.
Expand Down
2 changes: 1 addition & 1 deletion chain/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use std::time::{Duration, Instant};

use log::{debug, error, info, warn};
use near_primitives::time::Clock;
use tracing::{debug, error, info, warn};

use near_chain::chain::{
ApplyStatePartsRequest, BlockCatchUpRequest, BlockMissingChunks, BlocksCatchUpState,
Expand Down
2 changes: 1 addition & 1 deletion chain/client/src/client_actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use actix::{Actor, Addr, Arbiter, AsyncContext, Context, Handler, Message};
use actix_rt::ArbiterHandle;
use borsh::BorshSerialize;
use chrono::DateTime;
use log::{debug, error, info, trace, warn};
use near_chain::chain::{
do_apply_chunks, ApplyStatePartsRequest, ApplyStatePartsResponse, BlockCatchUpRequest,
BlockCatchUpResponse, StateSplitRequest, StateSplitResponse,
Expand Down Expand Up @@ -52,6 +51,7 @@ use std::collections::HashMap;
use std::sync::Arc;
use std::thread;
use std::time::{Duration, Instant};
use tracing::{debug, error, info, trace, warn};

/// Multiplier on `max_block_time` to wait until deciding that chain stalled.
const STATUS_WAIT_TIME_MULTIPLIER: u64 = 10;
Expand Down
2 changes: 1 addition & 1 deletion chain/client/src/info.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use crate::{metrics, SyncStatus};
use actix::Addr;
use log::info;
use near_chain_configs::{ClientConfig, LogSummaryStyle};
use near_client_primitives::types::ShardSyncStatus;
use near_network::types::NetworkInfo;
Expand All @@ -20,6 +19,7 @@ use std::cmp::min;
use std::fmt::Write;
use std::sync::Arc;
use sysinfo::{get_current_pid, set_open_files_limit, Pid, ProcessExt, System, SystemExt};
use tracing::info;

const TERAGAS: f64 = 1_000_000_000_000_f64;

Expand Down
2 changes: 1 addition & 1 deletion chain/client/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ use std::time::Duration as TimeDuration;
use ansi_term::Color::{Purple, Yellow};
use chrono::{DateTime, Duration};
use futures::{future, FutureExt};
use log::{debug, error, info, warn};
use rand::seq::{IteratorRandom, SliceRandom};
use rand::{thread_rng, Rng};
use tracing::{debug, error, info, warn};

use near_chain::{Chain, RuntimeAdapter};
use near_network::types::{FullPeerInfo, NetworkRequests, NetworkResponses, PeerManagerAdapter};
Expand Down
2 changes: 1 addition & 1 deletion chain/client/src/test_utils.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use log::info;
use std::cmp::max;
use std::collections::{HashMap, HashSet};
use std::mem::swap;
use std::ops::DerefMut;
use std::sync::{Arc, RwLock};
use std::time::Duration;
use tracing::info;

use actix::actors::mocker::Mocker;
use actix::{Actor, Addr, AsyncContext, Context};
Expand Down
2 changes: 1 addition & 1 deletion chain/client/src/view_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::sync::{Arc, Mutex, RwLock};
use std::time::{Duration, Instant};

use actix::{Actor, Addr, Handler, SyncArbiter, SyncContext};
use log::{debug, error, info, trace, warn};
use tracing::{debug, error, info, trace, warn};

use near_chain::types::ValidatorInfoIdentifier;
use near_chain::{
Expand Down
2 changes: 1 addition & 1 deletion chain/epoch_manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2021"
[dependencies]
# Changing this version will lead to change to the protocol, as will change how validators get shuffled.
protocol_defining_rand = { package = "rand", version = "0.6.5", default-features = false }
log = "0.4"
tracing = "0.1.13"
lru = "0.7.2"
borsh = "0.9"
rand = "0.7"
Expand Down
2 changes: 1 addition & 1 deletion chain/epoch_manager/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::cmp::Ordering;
use std::collections::{BTreeMap, HashMap, HashSet};

use log::{debug, warn};
use primitive_types::U256;
use tracing::{debug, warn};

use near_primitives::epoch_manager::block_info::BlockInfo;
use near_primitives::epoch_manager::epoch_info::{EpochInfo, EpochSummary};
Expand Down
2 changes: 1 addition & 1 deletion chain/epoch_manager/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::{BTreeMap, HashMap};

use borsh::{BorshDeserialize, BorshSerialize};
use log::error;
use tracing::error;

use near_primitives::epoch_manager::block_info::BlockInfo;
use near_primitives::epoch_manager::epoch_info::EpochInfo;
Expand Down
2 changes: 1 addition & 1 deletion core/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ description = "A fork of the lighthouse_metrics crate used to implement promethe
[dependencies]
lazy_static = "1.4"
prometheus = "0.11"
log = "0.4"
tracing = "0.1.13"
2 changes: 1 addition & 1 deletion core/metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub use prometheus::{
};
use prometheus::{HistogramOpts, HistogramTimer, Opts};

use log::error;
use tracing::error;

/// Collect all the metrics for reporting.
pub fn gather() -> Vec<prometheus::proto::MetricFamily> {
Expand Down
2 changes: 1 addition & 1 deletion core/store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ num_cpus = "1.11"
rand = "0.7"
strum = { version = "0.20", features = ["derive"] }
fs2 = "0.4"
tracing = "0.1"
tracing = "0.1.13"
borsh = "0.9"
thiserror = "1"
lru = "0.7.2"
Expand Down
1 change: 0 additions & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ chrono = { version = "0.4.4", features = ["serde"] }
futures = "0.3"
hex = "0.4"
hyper = { version = "0.14", features = ["full"] }
log = "0.4"
once_cell = "1.5"
primitive-types = "0.10.1"
rand = "0.7"
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/node/process_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::sync::Arc;
use std::time::Duration;
use std::{env, thread};

use log::error;
use rand::Rng;
use tracing::error;

use near_chain_configs::Genesis;
use near_crypto::{InMemorySigner, KeyType, Signer};
Expand Down
Loading

0 comments on commit ecc1756

Please sign in to comment.