Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

capture the standard error output from the running nodes #718

Merged
merged 2 commits into from Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 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 jormungandr-scenario-tests/Cargo.toml
Expand Up @@ -8,7 +8,7 @@ edition = "2018"

[dependencies]
slog = "2"
bawawa = "0.1.4"
bawawa = "0.1.5"
bytes = "0.4"
error-chain = "0.12"
tokio = "0.1"
Expand Down
13 changes: 13 additions & 0 deletions jormungandr-scenario-tests/src/node.rs
Expand Up @@ -209,6 +209,7 @@ impl Node {
&config_file.display().to_string(),
"--secret",
&config_secret.display().to_string(),
"--log-level=warn",
]);

match block0 {
Expand Down Expand Up @@ -239,6 +240,18 @@ impl Node {
Ok(node)
}

pub fn capture_logs(&mut self) -> impl Future<Item = (), Error = ()> {
let stderr = self.process.stderr().take().unwrap();

let stderr = tokio::codec::FramedRead::new(stderr, tokio::codec::LinesCodec::new());

let progress_bar = self.progress_bar.clone();

stderr
.for_each(move |line| future::ok(progress_bar.log_info(&line)))
.map_err(|err| unimplemented!("{}", err))
}

fn progress_bar_start(&self) {
self.progress_bar.set_style(
indicatif::ProgressStyle::default_spinner()
Expand Down
3 changes: 2 additions & 1 deletion jormungandr-scenario-tests/src/scenario/controller.rs
Expand Up @@ -148,7 +148,7 @@ impl Controller {
let pb = ProgressBar::new_spinner();
let pb = self.progress_bar.add(pb);

let node = Node::spawn(
let mut node = Node::spawn(
&self.context,
pb,
node_alias,
Expand All @@ -158,6 +158,7 @@ impl Controller {
)?;
let controller = node.controller();

self.runtime.executor().spawn(node.capture_logs());
self.runtime.executor().spawn(node);

Ok(controller)
Expand Down