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

Add stdout logging #720

Merged
merged 2 commits into from
Nov 27, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions binaries/daemon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1258,8 +1258,8 @@ impl Daemon {
NodeErrorCause::Cascading { caused_by_node }
}
None if grace_duration_kill => NodeErrorCause::GraceDuration,
None => NodeErrorCause::Other {
stderr: dataflow
None => {
let cause = dataflow
.and_then(|d| d.node_stderr_most_recent.get(&node_id))
.map(|queue| {
let mut s = if queue.is_full() {
Expand All @@ -1272,8 +1272,14 @@ impl Daemon {
}
s
})
.unwrap_or_default(),
},
.unwrap_or_default();

tracing::error!("node {dataflow_id}/{node_id} failed with:");
for line in cause.lines() {
tracing::error!(" {}", line);
}
NodeErrorCause::Other { stderr: cause }
}
};
Err(NodeError {
timestamp: self.clock.new_timestamp(),
Expand Down
7 changes: 6 additions & 1 deletion binaries/daemon/src/spawn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
let resolved_path = if source_is_url(source) {
// try to download the shared library
let target_dir = Path::new("build");
download_file(source, &target_dir)

Check warning on line 104 in binaries/daemon/src/spawn.rs

View workflow job for this annotation

GitHub Actions / Clippy

this expression creates a reference which is immediately dereferenced by the compiler
.await
.wrap_err("failed to download custom node")?
} else {
Expand Down Expand Up @@ -290,7 +290,7 @@
node_config,
};
let stdout_tx = tx.clone();

let node_id = node.id.clone();
// Stdout listener stream
tokio::spawn(async move {
let mut buffer = String::new();
Expand Down Expand Up @@ -337,6 +337,11 @@

// send the buffered lines
let lines = std::mem::take(&mut buffer);
if std::env::var("DORA_QUIET").is_err() {

Check warning on line 340 in binaries/daemon/src/spawn.rs

View workflow job for this annotation

GitHub Actions / Clippy

this `if` statement can be collapsed
if lines.len() > 1 {
tracing::info!("log_{}: {}", node_id, &lines[..lines.len() - 1]);
}
}
let sent = stdout_tx.send(lines.clone()).await;
if sent.is_err() {
println!("Could not log: {lines}");
Expand Down
Loading