Skip to content

Commit

Permalink
Use rust logging API (pantsbuild#5525)
Browse files Browse the repository at this point in the history
When in the engine, this passes messages up to python to log.

When in a standalone binary, this registers an env_logger.

Examples:

```
$ RUST_LOG=debug ./target/debug/process_executor --server=localhost:50000 --cas-server=localhost:50001 --local-store-path=${HOME}/tmp/store --input-digest=6f9a33e23a007c58c1e83f29bcf52979c797aba200cec0058695ff72d181e6ed --input-digest-length=85 -- /bin/bash -c "exit 42"
DEBUG 2018-02-27T15:23:19Z: process_execution::remote: Executing remotely request: action {command_digest {hash: "8a1eb3dc8694551ee161e6f616de205f7c2d5b52c8f5b93d2745d67c3b750e6a" size_bytes: 24} input_root_digest {hash: "6f9a33e23a007c58c1e83f29bcf52979c797aba200cec0058695ff72d181e6ed" size_bytes: 85}} (command: arguments: "/bin/bash" arguments: "-c" arguments: "exit 42")
DEBUG 2018-02-27T15:23:20Z: process_execution::remote: Got operation response: name: "b15e0908-7956-4dfa-7fc7-48dffc8aff8d" metadata {type_url: "type.googleapis.com/google.devtools.remoteexecution.v1test.ExecuteOperationMetadata" value: "\010\002\022E\n@81d6ae5c2323235c8633ffa63a1867bcc40306e0da9012a3d387df2eead80e3d\020\214\001"} response {type_url: "type.googleapis.com/google.devtools.remoteexecution.v1test.ExecuteResponse"}
```

```
$ ./pants -ldebug clean-all >/dev/null 2>/dev/null ; ./pants -ldebug list 3rdparty:: 2>&1 | grep Launching
DEBUG] Launching 2 roots.
DEBUG] Launching 1 roots.
DEBUG] Launching 2 roots.
```
  • Loading branch information
illicitonion authored Feb 28, 2018
1 parent 4e813c6 commit 1150d09
Show file tree
Hide file tree
Showing 14 changed files with 182 additions and 33 deletions.
2 changes: 2 additions & 0 deletions src/rust/engine/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/rust/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ fs = { path = "fs" }
futures = "0.1.16"
hashing = { path = "hashing" }
lazy_static = "0.2.2"
log = "0.4"
ordermap = "0.2.8"
petgraph = "0.4.5"
process_execution = { path = "process_execution" }
Expand Down
47 changes: 47 additions & 0 deletions src/rust/engine/fs/fs_util/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/rust/engine/fs/fs_util/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ bazel_protos = { path = "../../process_execution/bazel_protos" }
boxfuture = { path = "../../boxfuture" }
bytes = "0.4.5"
clap = "2"
env_logger = "0.5.4"
fs = { path = ".." }
futures = "0.1.16"
hashing = { path = "../../hashing" }
Expand Down
3 changes: 3 additions & 0 deletions src/rust/engine/fs/fs_util/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extern crate bazel_protos;
extern crate boxfuture;
extern crate bytes;
extern crate clap;
extern crate env_logger;
extern crate fs;
extern crate futures;
extern crate hashing;
Expand Down Expand Up @@ -37,6 +38,8 @@ impl From<String> for ExitError {
}

fn main() {
env_logger::init();

match execute(
App::new("fs_util")
.subcommand(
Expand Down
1 change: 1 addition & 0 deletions src/rust/engine/process_execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ fs = { path = "../fs" }
futures = "0.1.16"
grpcio = { version = "0.2.0", features = ["secure"] }
hashing = { path = "../hashing" }
log = "0.4"
protobuf = { version = "1.4.1", features = ["with-bytes"] }
sha2 = "0.6.0"
tempdir = "0.3.5"
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/process_execution/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ extern crate fs;
extern crate futures;
extern crate grpcio;
extern crate hashing;
#[macro_use]
extern crate log;
#[cfg(test)]
extern crate mock;
extern crate protobuf;
Expand Down
7 changes: 3 additions & 4 deletions src/rust/engine/process_execution/src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ impl CommandRunner {
Ok((command, execute_request)) => {
self.upload_command(&command, execute_request.get_action().get_command_digest().into())
.and_then(move |_| {
// TODO: Log less verbosely
println!("Executing remotely request: {:?} (command: {:?})", execute_request, command);
debug!("Executing remotely request: {:?} (command: {:?})", execute_request, command);

map_grpc_result(execution_client.execute(&execute_request))
.map(|result| (Arc::new(execute_request), result))
Expand Down Expand Up @@ -194,7 +193,7 @@ fn extract_execute_response(
mut operation: bazel_protos::operations::Operation,
) -> Result<ExecuteProcessResult, ExecutionError> {
// TODO: Log less verbosely
println!("Got operation response: {:?}", operation);
debug!("Got operation response: {:?}", operation);
if !operation.get_done() {
return Err(ExecutionError::NotFinished(operation.take_name()));
}
Expand All @@ -213,7 +212,7 @@ fn extract_execute_response(
ExecutionError::Fatal(format!("Invalid ExecuteResponse: {:?}", e))
})?;
// TODO: Log less verbosely
println!("Got (nested) execute response: {:?}", execute_response);
debug!("Got (nested) execute response: {:?}", execute_response);

match grpcio::RpcStatusCode::from(execute_response.get_status().get_code()) {
grpcio::RpcStatusCode::Ok => Ok(ExecuteProcessResult {
Expand Down
48 changes: 48 additions & 0 deletions src/rust/engine/process_executor/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1150d09

Please sign in to comment.