Changed the defaults for tracing to `false`. (#277)

* Changed the defaults for tracing to `false`.

* Cleanup envvar handling.

* Update `README.md`.
This commit is contained in:
Marc Brinkmann 2018-10-18 16:13:02 +02:00 committed by Andreas Fackler
parent c5ebdb5347
commit ba2390191f
2 changed files with 6 additions and 4 deletions

View File

@ -102,7 +102,7 @@ Adversaries can be introduced through the `.adversary` method on the constructor
By default, all network tests write traces of every network message into logfiles, named `net-trace_*.txt` in the current working directory. Each log stores one message per line, in the format of `[SENDER] -> [RECEIVER]: MSG`.
This behavior can be controlled using the `HBBFT_TEST_TRACE` environment variable; if set and equal to `0` or `false`, this functionality is disabled. Tracing is enabled by default.
This behavior can be controlled using the `HBBFT_TEST_TRACE` environment variable; if set and equal to `1` or `true`, this functionality is enabled. Tracing is disabled by default.
The `NetBuilder` allows hard-coding the trace setting, any value passed will override environment settings:

View File

@ -500,10 +500,12 @@ where
net.adversary = self.adversary;
}
// If the trace setting is not overriden, we use the setting from the environment.
let trace = self.trace.unwrap_or_else(|| {
// If the trace setting is not overriden, we use the setting from the environment.
let setting = env::var("HBBFT_TEST_TRACE").unwrap_or_else(|_| "true".to_string());
!(setting == "false" || setting == "0")
match env::var("HBBFT_TEST_TRACE").as_ref().map(|s| s.as_str()) {
Ok("true") | Ok("1") => true,
_ => false,
}
});
if trace {