Skip to content

Commit 84f5504

Browse files
vmxdignifiedquire
authored andcommitted
refactor: use fil_logger instead of pretty_env_logger
The log output changes and now looks like the one [IPFS go-log] is producing. You can also toggle the output to JSON with setting the environment variable `GOLOG_LOG_FMT=json`. Example for console outpute: ```console $ RUST_LOG=debug cargo run --example stacked -- --size 16 Finished dev [unoptimized + debuginfo] target(s) in 0.15s Running `/home/vmx/src/pl/filecoin/rust-fil-proofs/target/debug/examples/stacked --size 16` 2019-11-14T19:42:35.240 INFO stacked > hasher: pedersen 2019-11-14T19:42:35.240 INFO stacked > data size: 16 kB 2019-11-14T19:42:35.240 INFO stacked > m: 6 2019-11-14T19:42:35.240 INFO stacked > expansion_degree: 8 2019-11-14T19:42:35.240 INFO stacked > layer_challenges: LayerChallenges { layers: 10, max_count: 1 } 2019-11-14T19:42:35.240 INFO stacked > layers: 10 2019-11-14T19:42:35.240 INFO stacked > partitions: 1 2019-11-14T19:42:35.240 INFO stacked > circuit: false 2019-11-14T19:42:35.240 INFO stacked > groth: false 2019-11-14T19:42:35.240 INFO stacked > bench: false 2019-11-14T19:42:35.241 INFO stacked > running setup 2019-11-14T19:42:35.241 INFO stacked > setup complete 2019-11-14T19:42:35.241 INFO stacked > generating zeroed data 2019-11-14T19:42:35.241 INFO stacked > running replicate 2019-11-14T19:42:35.241 INFO storage_proofs::stacked::proof > building merkle tree for the original data 2019-11-14T19:42:35.241 INFO storage_proofs::stacked::proof > generate labels 2019-11-14T19:42:35.242 INFO storage_proofs::stacked::proof > hashing columns with 7 chunks 2019-11-14T19:42:35.243 INFO storage_proofs::stacked::proof > generating layer: 1 2019-11-14T19:42:35.636 INFO storage_proofs::stacked::proof > generating layer: 2 2019-11-14T19:42:36.041 INFO storage_proofs::stacked::proof > generating layer: 3 2019-11-14T19:42:36.443 INFO storage_proofs::stacked::proof > generating layer: 4 2019-11-14T19:42:36.843 INFO storage_proofs::stacked::proof > generating layer: 5 2019-11-14T19:42:37.243 INFO storage_proofs::stacked::proof > generating layer: 6 2019-11-14T19:42:37.648 INFO storage_proofs::stacked::proof > generating layer: 7 2019-11-14T19:42:38.060 INFO storage_proofs::stacked::proof > generating layer: 8 2019-11-14T19:42:38.460 INFO storage_proofs::stacked::proof > generating layer: 9 2019-11-14T19:42:38.859 INFO storage_proofs::stacked::proof > generating layer: 10 2019-11-14T19:43:36.429 INFO storage_proofs::stacked::proof > Labels generated 2019-11-14T19:43:36.429 INFO storage_proofs::stacked::proof > encoding data 2019-11-14T19:43:36.429 INFO storage_proofs::stacked::proof > building tree_c 2019-11-14T19:43:36.432 INFO storage_proofs::stacked::proof > building tree_r_last 2019-11-14T19:43:36.965 INFO storage_proofs::stacked::proof > tree_c done 2019-11-14T19:43:36.965 INFO storage_proofs::stacked::proof > tree_r_last done 2019-11-14T19:43:36.968 INFO stacked > replication_time: 61.727274001s 2019-11-14T19:43:36.968 INFO stacked > replication_time/byte: 3.767533ms 2019-11-14T19:43:36.968 INFO stacked > replication_time/GiB: 4045357.755400192s 2019-11-14T19:43:36.969 INFO stacked > generating 1 partition proofs 2019-11-14T19:43:36.974 INFO stacked > vanilla_proving_time: 4.922457ms 2019-11-14T19:43:36.974 INFO stacked > sampling verifying (samples: 5) 2019-11-14T19:43:40.364 INFO stacked > Verification complete 2019-11-14T19:43:40.364 INFO stacked > average_vanilla_verifying_time: 0.678136971 seconds ``` Example for JSON output: ```console $ RUST_LOG=debug GOLOG_LOG_FMT=json cargo run --example stacked -- --size 16 Finished dev [unoptimized + debuginfo] target(s) in 0.15s Running `/home/vmx/src/pl/filecoin/rust-fil-proofs/target/debug/examples/stacked --size 16` {"level":"info","ts":"2019-11-14T19:44:43.519+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:483","msg":"hasher: pedersen"}" {"level":"info","ts":"2019-11-14T19:44:43.519+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:160","msg":"data size: 16 kB"}" {"level":"info","ts":"2019-11-14T19:44:43.519+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:161","msg":"m: 6"}" {"level":"info","ts":"2019-11-14T19:44:43.519+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:162","msg":"expansion_degree: 8"}" {"level":"info","ts":"2019-11-14T19:44:43.519+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:163","msg":"layer_challenges: LayerChallenges { layers: 10, max_count: 1 }"}" {"level":"info","ts":"2019-11-14T19:44:43.519+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:164","msg":"layers: 10"}" {"level":"info","ts":"2019-11-14T19:44:43.519+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:165","msg":"partitions: 1"}" {"level":"info","ts":"2019-11-14T19:44:43.519+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:166","msg":"circuit: false"}" {"level":"info","ts":"2019-11-14T19:44:43.519+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:167","msg":"groth: false"}" {"level":"info","ts":"2019-11-14T19:44:43.519+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:168","msg":"bench: false"}" {"level":"info","ts":"2019-11-14T19:44:43.519+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:181","msg":"running setup"}" {"level":"info","ts":"2019-11-14T19:44:43.520+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:184","msg":"setup complete"}" {"level":"info","ts":"2019-11-14T19:44:43.520+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:115","msg":"generating zeroed data"}" {"level":"info","ts":"2019-11-14T19:44:43.520+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:198","msg":"running replicate"}" {"level":"info","ts":"2019-11-14T19:44:43.520+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:445","msg":"building merkle tree for the original data"}" {"level":"info","ts":"2019-11-14T19:44:43.520+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:244","msg":"generate labels"}" {"level":"info","ts":"2019-11-14T19:44:43.520+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:275","msg":"hashing columns with 7 chunks"}" {"level":"info","ts":"2019-11-14T19:44:43.521+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:311","msg":"generating layer: 1"}" {"level":"info","ts":"2019-11-14T19:44:43.921+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:311","msg":"generating layer: 2"}" {"level":"info","ts":"2019-11-14T19:44:44.346+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:311","msg":"generating layer: 3"}" {"level":"info","ts":"2019-11-14T19:44:44.755+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:311","msg":"generating layer: 4"}" {"level":"info","ts":"2019-11-14T19:44:45.161+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:311","msg":"generating layer: 5"}" {"level":"info","ts":"2019-11-14T19:44:45.568+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:311","msg":"generating layer: 6"}" {"level":"info","ts":"2019-11-14T19:44:45.969+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:311","msg":"generating layer: 7"}" {"level":"info","ts":"2019-11-14T19:44:46.375+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:311","msg":"generating layer: 8"}" {"level":"info","ts":"2019-11-14T19:44:46.781+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:311","msg":"generating layer: 9"}" {"level":"info","ts":"2019-11-14T19:44:47.189+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:311","msg":"generating layer: 10"}" {"level":"info","ts":"2019-11-14T19:45:45.272+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:406","msg":"Labels generated"}" {"level":"info","ts":"2019-11-14T19:45:45.273+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:460","msg":"encoding data"}" {"level":"info","ts":"2019-11-14T19:45:45.273+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:482","msg":"building tree_c"}" {"level":"info","ts":"2019-11-14T19:45:45.276+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:476","msg":"building tree_r_last"}" {"level":"info","ts":"2019-11-14T19:45:45.786+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:495","msg":"tree_c done"}" {"level":"info","ts":"2019-11-14T19:45:45.795+01:00","logger":"storage_proofs::stacked::proof","caller":"storage-proofs/src/stacked/proof.rs:497","msg":"tree_r_last done"}" {"level":"info","ts":"2019-11-14T19:45:45.797+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:216","msg":"replication_time: 62.277651547s"}" {"level":"info","ts":"2019-11-14T19:45:45.798+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:230","msg":"replication_time/byte: 3.801125ms"}" {"level":"info","ts":"2019-11-14T19:45:45.798+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:231","msg":"replication_time/GiB: 4081426.890752s"}" {"level":"info","ts":"2019-11-14T19:45:45.798+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:233","msg":"generating 1 partition proofs"}" {"level":"info","ts":"2019-11-14T19:45:45.802+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:248","msg":"vanilla_proving_time: 3.957739ms"}" {"level":"info","ts":"2019-11-14T19:45:45.802+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:253","msg":"sampling verifying (samples: 5)"}" {"level":"info","ts":"2019-11-14T19:45:49.456+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:270","msg":"Verification complete"}" {"level":"info","ts":"2019-11-14T19:45:49.456+01:00","logger":"stacked","caller":"filecoin-proofs/examples/stacked.rs:276","msg":"average_vanilla_verifying_time: 0.730860279 seconds"}" ``` [IPFS go-log]: https://github.com/ipfs/go-log
1 parent 4f329d6 commit 84f5504

File tree

10 files changed

+19
-13
lines changed

10 files changed

+19
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ For development purposes we have an (experimental) support for CPU and memory pr
100100

101101
For better logging with backtraces on errors, developers should use `expects` rather than `expect` on `Result<T, E>` and `Option<T>`.
102102

103-
The crate use [`log`](https://crates.io/crates/log) for logging, which by default does not log at all. In order to log output crates like [`pretty_env_logger`](https://crates.io/crates/pretty_env_logger) can be used.
103+
The crate use [`log`](https://crates.io/crates/log) for logging, which by default does not log at all. In order to log output crates like [`fil_logger`](https://crates.io/crates/fil_logger) can be used.
104104

105105
For example
106106

107107
```rust
108108
fn main() {
109-
pretty_env_logger::init();
109+
fil_logger::init();
110110
}
111111
```
112112

fil-proofs-tooling/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ heim = "0.0.8"
3636
futures-preview = "0.3.0-alpha.17"
3737
raw-cpuid = "7.0.3"
3838
blake2s_simd = "0.5.6"
39-
pretty_env_logger = "0.3.1"
39+
fil_logger = "0.1"
4040
log = "0.4.8"
4141
uom = "0.25.0"
4242
merkletree = "0.13.0"

fil-proofs-tooling/src/bin/benchy/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ mod hash_fns;
88
mod stacked;
99

1010
fn main() {
11-
pretty_env_logger::init_timed();
11+
fil_logger::init();
1212

1313
let stacked_cmd = SubCommand::with_name("stacked")
1414
.about("Run stacked sealing")

filecoin-proofs/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ paired = "0.16.0"
3131
fil-sapling-crypto = "0.2.0"
3232
clap = "2"
3333
log = "0.4.7"
34-
pretty_env_logger = "0.3.0"
34+
fil_logger = "0.1"
3535
env_proxy = "0.3"
3636
os_type = "2.2.0"
3737
flate2 = { version = "1.0.9", features = ["rust_backend"]}
@@ -54,7 +54,6 @@ features = ["default-tls-vendored"]
5454
gperftools = "0.2"
5555
criterion = "0.3"
5656
rexpect = "0.3.0"
57-
pretty_env_logger = "0.3.1"
5857
pretty_assertions = "0.6.1"
5958
rand_xorshift = "0.2.0"
6059
failure = "0.1"

filecoin-proofs/examples/stacked.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ fn do_the_work<H: 'static>(
415415
}
416416

417417
fn main() {
418-
pretty_env_logger::init_timed();
418+
fil_logger::init();
419419

420420
let matches = App::new(stringify!("DrgPoRep Vanilla Bench"))
421421
.version("1.0")

filecoin-proofs/src/api/mod.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ mod tests {
276276

277277
use std::collections::BTreeMap;
278278
use std::io::{Seek, SeekFrom, Write};
279+
use std::sync::Once;
279280

280281
use ff::Field;
281282
use paired::bls12_381::{Bls12, Fr};
@@ -290,6 +291,13 @@ mod tests {
290291
};
291292
use crate::types::{PoStConfig, SectorSize};
292293

294+
static INIT_LOGGER: Once = Once::new();
295+
fn init_logger() {
296+
INIT_LOGGER.call_once(|| {
297+
fil_logger::init();
298+
});
299+
}
300+
293301
#[test]
294302
fn test_verify_seal_fr32_validation() {
295303
let convertible_to_fr_bytes = [0; 32];
@@ -362,7 +370,7 @@ mod tests {
362370
#[test]
363371
#[ignore]
364372
fn test_verify_post_fr32_validation() {
365-
pretty_env_logger::try_init().ok();
373+
init_logger();
366374

367375
let not_convertible_to_fr_bytes = [255; 32];
368376
let out = bytes_into_fr::<Bls12>(&not_convertible_to_fr_bytes);
@@ -408,7 +416,7 @@ mod tests {
408416
#[test]
409417
#[ignore]
410418
fn test_seal_lifecycle() -> Result<()> {
411-
pretty_env_logger::try_init().ok();
419+
init_logger();
412420

413421
let rng = &mut XorShiftRng::from_seed(crate::TEST_SEED);
414422

filecoin-proofs/src/bin/paramcache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ fn cache_post_params(post_config: PoStConfig) {
117117

118118
// Run this from the command-line to pre-generate the groth parameters used by the API.
119119
pub fn main() {
120-
pretty_env_logger::init_timed();
120+
fil_logger::init();
121121

122122
let matches = App::new("paramcache")
123123
.version("0.1")

filecoin-proofs/src/bin/paramfetch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl<R: Read> Read for FetchProgress<R> {
4444
}
4545

4646
pub fn main() {
47-
pretty_env_logger::init_timed();
47+
fil_logger::init();
4848

4949
let matches = App::new("paramfetch")
5050
.version("1.1")

filecoin-proofs/src/bin/parampublish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const ERROR_IPFS_COMMAND: &str = "failed to run ipfs";
2323
const ERROR_IPFS_PUBLISH: &str = "failed to publish via ipfs";
2424

2525
pub fn main() {
26-
pretty_env_logger::init_timed();
26+
fil_logger::init();
2727

2828
let matches = App::new("parampublish")
2929
.version("1.0")

storage-proofs/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ paired = { version = "0.16.0", features = ["serde"] }
4444
fil-sapling-crypto = "0.2.0"
4545
serde_json = "1.0"
4646
log = "0.4.7"
47-
pretty_env_logger = "0.3.0"
4847
pretty_assertions = "0.6.1"
4948
crossbeam = "0.7.2"
5049
num_cpus = "1.10.1"

0 commit comments

Comments
 (0)