Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Update log -> 0.4, env_logger -> 0.5.
Browse files Browse the repository at this point in the history
* Rename a few types & methods.
* Change `(Log)Builder::format` (closure) arg.
  • Loading branch information
c0gent committed Aug 6, 2018
1 parent e8b13cb commit 1569cef
Show file tree
Hide file tree
Showing 37 changed files with 155 additions and 97 deletions.
142 changes: 100 additions & 42 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
blooms-db = { path = "util/blooms-db" }
log = "0.3"
env_logger = "0.4"
log = "0.4"
env_logger = "0.5"
rustc-hex = "1.0"
docopt = "0.8"
clap = "2"
Expand Down
2 changes: 1 addition & 1 deletion ethash/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
[lib]

[dependencies]
log = "0.3"
log = "0.4"
keccak-hash = { git = "https://github.com/paritytech/parity-common" }
primal = "0.2.3"
parking_lot = "0.6"
Expand Down
2 changes: 1 addition & 1 deletion ethcore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ evm = { path = "evm" }
heapsize = "0.4"
itertools = "0.5"
lazy_static = "1.0"
log = "0.3"
log = "0.4"
lru-cache = "0.1"
num = { version = "0.1", default-features = false, features = ["bigint"] }
num_cpus = "1.2"
Expand Down
2 changes: 1 addition & 1 deletion ethcore/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ bit-set = "0.4"
ethereum-types = "0.3"
heapsize = "0.4"
lazy_static = "1.0"
log = "0.3"
log = "0.4"
vm = { path = "../vm" }
keccak-hash = { git = "https://github.com/paritytech/parity-common" }
parking_lot = "0.6"
Expand Down
2 changes: 1 addition & 1 deletion ethcore/light/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version = "1.12.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
log = "0.3"
log = "0.4"
ethcore = { path = ".."}
parity-bytes = { git = "https://github.com/paritytech/parity-common" }
ethcore-transaction = { path = "../transaction" }
Expand Down
2 changes: 1 addition & 1 deletion ethcore/node_filter/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ethcore = { path = ".."}
ethcore-network = { path = "../../util/network" }
ethcore-network-devp2p = { path = "../../util/network-devp2p" }
ethereum-types = "0.3"
log = "0.3"
log = "0.4"
parking_lot = "0.6"
ethabi = "5.1"
ethabi-derive = "5.0"
Expand Down
2 changes: 1 addition & 1 deletion ethcore/private-tx/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ ethkey = { path = "../../ethkey" }
fetch = { path = "../../util/fetch" }
futures = "0.1"
keccak-hash = { git = "https://github.com/paritytech/parity-common" }
log = "0.3"
log = "0.4"
parking_lot = "0.6"
patricia-trie = { git = "https://github.com/paritytech/parity-common" }
patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" }
Expand Down
2 changes: 1 addition & 1 deletion ethcore/service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ethcore-io = { path = "../../util/io" }
ethcore-private-tx = { path = "../private-tx" }
ethcore-sync = { path = "../sync" }
kvdb = { git = "https://github.com/paritytech/parity-common" }
log = "0.3"
log = "0.4"
stop-guard = { path = "../../util/stop-guard" }
trace-time = { path = "../../util/trace-time" }

Expand Down
4 changes: 2 additions & 2 deletions ethcore/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ fn enact(
ancestry: &mut Iterator<Item=ExtendedHeader>,
) -> Result<LockedBlock, Error> {
{
if ::log::max_log_level() >= ::log::LogLevel::Trace {
if ::log::max_level() >= ::log::Level::Trace {
let s = State::from_existing(db.boxed_clone(), parent.state_root().clone(), engine.account_start_nonce(parent.number() + 1), factories.clone())?;
trace!(target: "enact", "num={}, root={}, author={}, author_balance={}\n",
header.number(), s.root(), header.author(), s.balance(&header.author())?);
Expand Down Expand Up @@ -659,7 +659,7 @@ mod tests {
let transactions = transactions?;

{
if ::log::max_log_level() >= ::log::LogLevel::Trace {
if ::log::max_level() >= ::log::Level::Trace {
let s = State::from_existing(db.boxed_clone(), parent.state_root().clone(), engine.account_start_nonce(parent.number() + 1), factories.clone())?;
trace!(target: "enact", "num={}, root={}, author={}, author_balance={}\n",
header.number(), s.root(), header.author(), s.balance(&header.author())?);
Expand Down
4 changes: 2 additions & 2 deletions ethcore/stratum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ keccak-hash = { git = "https://github.com/paritytech/parity-common" }
jsonrpc-core = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
jsonrpc-macros = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
jsonrpc-tcp-server = { git = "https://github.com/paritytech/jsonrpc.git", branch = "parity-1.11" }
log = "0.3"
log = "0.4"
parking_lot = "0.6"

[dev-dependencies]
env_logger = "0.4"
env_logger = "0.5"
tokio-core = "0.1"
tokio-io = "0.1"
ethcore-logger = { path = "../../logger" }
4 changes: 2 additions & 2 deletions ethcore/sync/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ keccak-hasher = { path = "../../util/keccak-hasher" }
triehash-ethereum = {version = "0.2", path = "../../util/triehash-ethereum" }
kvdb = { git = "https://github.com/paritytech/parity-common" }
macros = { path = "../../util/macros" }
log = "0.3"
env_logger = "0.4"
log = "0.4"
env_logger = "0.5"
rand = "0.4"
heapsize = "0.4"
semver = "0.9"
Expand Down
2 changes: 1 addition & 1 deletion ethcore/vm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ parity-bytes = { git = "https://github.com/paritytech/parity-common" }
ethereum-types = "0.3"
patricia-trie = { git = "https://github.com/paritytech/parity-common" }
patricia-trie-ethereum = { path = "../../util/patricia-trie-ethereum" }
log = "0.3"
log = "0.4"
common-types = { path = "../types" }
ethjson = { path = "../../json" }
rlp = { git = "https://github.com/paritytech/parity-common" }
Expand Down
2 changes: 1 addition & 1 deletion ethcore/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
byteorder = "1.0"
ethereum-types = "0.3"
log = "0.3"
log = "0.4"
parity-wasm = "0.31"
libc = "0.2"
pwasm-utils = "0.2.2"
Expand Down
2 changes: 1 addition & 1 deletion ethkey/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ parity-crypto = { git = "https://github.com/paritytech/parity-common" }
eth-secp256k1 = { git = "https://github.com/paritytech/rust-secp256k1" }
ethereum-types = "0.3"
lazy_static = "1.0"
log = "0.3"
log = "0.4"
mem = { path = "../util/mem" }
parity-wordlist = "1.2"
quick-error = "1.2.2"
Expand Down
2 changes: 1 addition & 1 deletion ethkey/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
docopt = "0.8"
env_logger = "0.4"
env_logger = "0.5"
ethkey = { path = "../" }
panic_hook = { path = "../../util/panic_hook" }
parity-wordlist="1.2"
Expand Down
2 changes: 1 addition & 1 deletion ethstore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.2.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
log = "0.3"
log = "0.4"
libc = "0.2"
rand = "0.4"
ethkey = { path = "../ethkey" }
Expand Down
2 changes: 1 addition & 1 deletion hash-fetch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
futures = "0.1"
futures-cpupool = "0.1"
log = "0.3"
log = "0.4"
mime = "0.3"
mime_guess = "2.0.0-alpha.2"
rand = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion hw/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version = "1.12.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
log = "0.3"
log = "0.4"
parking_lot = "0.6"
protobuf = "1.4"
hidapi = { git = "https://github.com/paritytech/hidapi-rs" }
Expand Down
2 changes: 1 addition & 1 deletion local-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ethcore = { path = "../ethcore" }
ethcore-io = { path = "../util/io" }
ethcore-transaction = { path = "../ethcore/transaction" }
kvdb = { git = "https://github.com/paritytech/parity-common" }
log = "0.3"
log = "0.4"
rlp = { git = "https://github.com/paritytech/parity-common" }
serde = "1.0"
serde_derive = "1.0"
Expand Down
4 changes: 2 additions & 2 deletions logger/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ license = "GPL-3.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
log = "0.3"
env_logger = "0.4"
log = "0.4"
env_logger = "0.5"
atty = "0.2"
lazy_static = "1.0"
regex = "0.2"
Expand Down
22 changes: 11 additions & 11 deletions logger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ mod rotating;
use std::{env, thread, fs};
use std::sync::{Weak, Arc};
use std::io::Write;
use env_logger::LogBuilder;
use env_logger::{Builder as LogBuilder, Formatter};
use regex::Regex;
use ansi_term::Colour;
use parking_lot::Mutex;
Expand Down Expand Up @@ -68,12 +68,12 @@ pub fn setup_log(config: &Config) -> Result<Arc<RotatingLogger>, String> {
let mut levels = String::new();
let mut builder = LogBuilder::new();
// Disable info logging by default for some modules:
builder.filter(Some("ws"), LogLevelFilter::Warn);
builder.filter(Some("reqwest"), LogLevelFilter::Warn);
builder.filter(Some("hyper"), LogLevelFilter::Warn);
builder.filter(Some("rustls"), LogLevelFilter::Error);
builder.filter(Some("ws"), LevelFilter::Warn);
builder.filter(Some("reqwest"), LevelFilter::Warn);
builder.filter(Some("hyper"), LevelFilter::Warn);
builder.filter(Some("rustls"), LevelFilter::Error);
// Enable info for others.
builder.filter(None, LogLevelFilter::Info);
builder.filter(None, LevelFilter::Info);

if let Ok(lvl) = env::var("RUST_LOG") {
levels.push_str(&lvl);
Expand All @@ -99,10 +99,10 @@ pub fn setup_log(config: &Config) -> Result<Arc<RotatingLogger>, String> {
None => None,
};

let format = move |record: &LogRecord| {
let format = move |buf: &mut Formatter, record: &Record| {
let timestamp = time::strftime("%Y-%m-%d %H:%M:%S %Z", &time::now()).unwrap();

let with_color = if max_log_level() <= LogLevelFilter::Info {
let with_color = if max_level() <= LevelFilter::Info {
format!("{} {}", Colour::Black.bold().paint(timestamp), record.args())
} else {
let name = thread::current().name().map_or_else(Default::default, |x| format!("{}", Colour::Blue.bold().paint(x)));
Expand All @@ -122,16 +122,16 @@ pub fn setup_log(config: &Config) -> Result<Arc<RotatingLogger>, String> {
let _ = file.write_all(b"\n");
}
logger.append(removed_color);
if !isatty && record.level() <= LogLevel::Info && atty::is(atty::Stream::Stdout) {
if !isatty && record.level() <= Level::Info && atty::is(atty::Stream::Stdout) {
// duplicate INFO/WARN output to console
println!("{}", ret);
}

ret
write!(buf, "{}", ret)
};

builder.format(format);
builder.init()
builder.try_init()
.and_then(|_| {
*ROTATING_LOGGER.lock() = Arc::downgrade(&logs);
Ok(logs)
Expand Down
8 changes: 4 additions & 4 deletions logger/src/rotating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
//! Common log helper functions

use std::env;
use rlog::LogLevelFilter;
use env_logger::LogBuilder;
use rlog::LevelFilter;
use env_logger::Builder as LogBuilder;
use arrayvec::ArrayVec;

use parking_lot::{RwLock, RwLockReadGuard};

lazy_static! {
static ref LOG_DUMMY: () = {
let mut builder = LogBuilder::new();
builder.filter(None, LogLevelFilter::Info);
builder.filter(None, LevelFilter::Info);

if let Ok(log) = env::var("RUST_LOG") {
builder.parse(&log);
}

if !builder.init().is_ok() {
if !builder.try_init().is_ok() {
println!("logger initialization failed!");
}
};
Expand Down
4 changes: 2 additions & 2 deletions miner/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ futures-cpupool = "0.1"
heapsize = "0.4"
keccak-hash = { git = "https://github.com/paritytech/parity-common" }
linked-hash-map = "0.5"
log = "0.3"
log = "0.4"
parking_lot = "0.6"
price-info = { path = "../price-info", optional = true }
rlp = { git = "https://github.com/paritytech/parity-common" }
trace-time = { path = "../util/trace-time" }
transaction-pool = { path = "../transaction-pool" }

[dev-dependencies]
env_logger = "0.4"
env_logger = "0.5"
ethkey = { path = "../ethkey" }
rustc-hex = "1.0"

Expand Down
2 changes: 1 addition & 1 deletion price-info/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
fetch = { path = "../util/fetch" }
futures = "0.1"
futures-cpupool = "0.1"
log = "0.3"
log = "0.4"
serde_json = "1.0"

[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ansi_term = "0.10"
cid = "0.2"
futures = "0.1.6"
futures-cpupool = "0.1"
log = "0.3"
log = "0.4"
multihash ="0.7"
order-stat = "0.1"
parking_lot = "0.6"
Expand Down
2 changes: 1 addition & 1 deletion secret_store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
byteorder = "1.0"
log = "0.3"
log = "0.4"
parking_lot = "0.6"
hyper = { version = "0.11", default-features = false }
serde = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion transaction-pool/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
error-chain = "0.12"
log = "0.3"
log = "0.4"
smallvec = "0.4"
trace-time = { path = "../util/trace-time", version = "0.1" }

Expand Down
2 changes: 1 addition & 1 deletion updater/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ authors = ["Parity Technologies <admin@parity.io>"]
[dependencies]
keccak-hash = { git = "https://github.com/paritytech/parity-common" }
lazy_static = "1.0"
log = "0.3"
log = "0.4"
ethabi = "5.1"
ethabi-derive = "5.0"
ethabi-contract = "5.0"
Expand Down
2 changes: 1 addition & 1 deletion util/io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fnv = "1.0"
mio = { version = "0.6.8", optional = true }
crossbeam = "0.3"
parking_lot = "0.6"
log = "0.3"
log = "0.4"
slab = "0.4"
num_cpus = "1.8"
timer = "0.2"
Expand Down
2 changes: 1 addition & 1 deletion util/journaldb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ hashdb = { git = "https://github.com/paritytech/parity-common" }
heapsize = "0.4"
keccak-hasher = { path = "../keccak-hasher" }
kvdb = { git = "https://github.com/paritytech/parity-common" }
log = "0.3"
log = "0.4"
memorydb = { git = "https://github.com/paritytech/parity-common" }
parking_lot = "0.6"
plain_hasher = { git = "https://github.com/paritytech/parity-common" }
Expand Down
2 changes: 1 addition & 1 deletion util/migration-rocksdb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
log = "0.3"
log = "0.4"
macros = { path = "../macros" }
kvdb = { git = "https://github.com/paritytech/parity-common" }
kvdb-rocksdb = { git = "https://github.com/paritytech/parity-common" }
Expand Down
2 changes: 1 addition & 1 deletion util/network-devp2p/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ version = "1.12.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
log = "0.3"
log = "0.4"
mio = "0.6.8"
bytes = "0.4"
rand = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion util/stats/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]

[dependencies]
log = "0.3"
log = "0.4"
2 changes: 1 addition & 1 deletion util/trace-time/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ authors = ["Parity Technologies <admin@parity.io>"]
license = "GPL-3.0"

[dependencies]
log = "0.3"
log = "0.4"
Loading

0 comments on commit 1569cef

Please sign in to comment.