Coloured, padding logging. (#1133)

* Add info message for mined block.

* Coloured, padding logging.

* Remove superfluous logs.

* Use better term colour module.
This commit is contained in:
Gav Wood 2016-05-24 20:30:21 +02:00
parent 2969d015ed
commit 27380cdadb
4 changed files with 30 additions and 16 deletions

6
Cargo.lock generated
View File

@ -2,6 +2,7 @@
name = "parity" name = "parity"
version = "1.2.0" version = "1.2.0"
dependencies = [ dependencies = [
"ansi_term 0.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
"clippy 0.0.67 (registry+https://github.com/rust-lang/crates.io-index)", "clippy 0.0.67 (registry+https://github.com/rust-lang/crates.io-index)",
"ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)", "ctrlc 1.1.1 (git+https://github.com/ethcore/rust-ctrlc.git)",
"daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", "daemonize 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -39,6 +40,11 @@ dependencies = [
"memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "ansi_term"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.3.16" version = "0.3.16"

View File

@ -33,8 +33,9 @@ ethcore-rpc = { path = "rpc", optional = true }
ethcore-webapp = { path = "webapp", optional = true } ethcore-webapp = { path = "webapp", optional = true }
semver = "0.2" semver = "0.2"
ethcore-ipc-nano = { path = "ipc/nano" } ethcore-ipc-nano = { path = "ipc/nano" }
"ethcore-ipc" = { path = "ipc/rpc" } ethcore-ipc = { path = "ipc/rpc" }
json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" } json-ipc-server = { git = "https://github.com/ethcore/json-ipc-server.git" }
ansi_term = "0.7"
[dependencies.hyper] [dependencies.hyper]
version = "0.8" version = "0.8"

View File

@ -14,9 +14,13 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>. // along with Parity. If not, see <http://www.gnu.org/licenses/>.
extern crate ansi_term;
use std::sync::RwLock; use std::sync::RwLock;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
use ansi_term::Colour::*;
use ethsync::{EthSync, SyncProvider}; use ethsync::{EthSync, SyncProvider};
use util::Uint;
use ethcore::client::*; use ethcore::client::*;
use number_prefix::{binary_prefix, Standalone, Prefixed}; use number_prefix::{binary_prefix, Standalone, Prefixed};
@ -61,23 +65,25 @@ impl Informant {
self.cache_info.read().unwrap().deref(), self.cache_info.read().unwrap().deref(),
write_report.deref() write_report.deref()
) { ) {
println!("[ #{} {} ]---[ {} blk/s | {} tx/s | {} gas/s //··· {}/{} peers, #{}, {}+{} queued ···// mem: {} db, {} chain, {} queue, {} sync ]", println!("#{} {} {} blk/s {} tx/s {} Kgas/s {}/{} peers #{} {}+{} Qed {} db {} chain {} queue {} sync",
chain_info.best_block_number, White.bold().paint(format!("{:<7}", chain_info.best_block_number)),
chain_info.best_block_hash, White.bold().paint(format!("{}", chain_info.best_block_hash)),
(report.blocks_imported - last_report.blocks_imported) / dur,
(report.transactions_applied - last_report.transactions_applied) / dur,
(report.gas_processed - last_report.gas_processed) / From::from(dur),
sync_info.num_active_peers, Yellow.bold().paint(format!("{:3}", (report.blocks_imported - last_report.blocks_imported) / dur)),
sync_info.num_peers, Yellow.bold().paint(format!("{:3}", (report.transactions_applied - last_report.transactions_applied) / dur)),
sync_info.last_imported_block_number.unwrap_or(chain_info.best_block_number), Yellow.bold().paint(format!("{:4}", ((report.gas_processed - last_report.gas_processed) / From::from(dur * 1000)).low_u64())),
queue_info.unverified_queue_size,
queue_info.verified_queue_size,
Informant::format_bytes(report.state_db_mem), Green.bold().paint(format!("{:2}", sync_info.num_active_peers)),
Informant::format_bytes(cache_info.total()), Green.bold().paint(format!("{:2}", sync_info.num_peers)),
Informant::format_bytes(queue_info.mem_used),
Informant::format_bytes(sync_info.mem_used), Cyan.bold().paint(format!("{:<7}", sync_info.last_imported_block_number.unwrap_or(chain_info.best_block_number))),
Blue.bold().paint(format!("{:4}", queue_info.unverified_queue_size)),
Blue.bold().paint(format!("{:4}", queue_info.verified_queue_size)),
Purple.bold().paint(format!("{:>8}", Informant::format_bytes(report.state_db_mem))),
Purple.bold().paint(format!("{:>8}", Informant::format_bytes(cache_info.total()))),
Purple.bold().paint(format!("{:>8}", Informant::format_bytes(queue_info.mem_used))),
Purple.bold().paint(format!("{:>8}", Informant::format_bytes(sync_info.mem_used))),
); );
} }

View File

@ -22,6 +22,7 @@
#![cfg_attr(feature="dev", allow(useless_format))] #![cfg_attr(feature="dev", allow(useless_format))]
extern crate docopt; extern crate docopt;
extern crate ansi_term;
extern crate num_cpus; extern crate num_cpus;
extern crate rustc_serialize; extern crate rustc_serialize;
extern crate ethcore_util as util; extern crate ethcore_util as util;