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

There are still some logs with --output-json #1155

Open
kvinwang opened this issue Jun 10, 2023 · 3 comments
Open

There are still some logs with --output-json #1155

kvinwang opened this issue Jun 10, 2023 · 3 comments

Comments

@kvinwang
Copy link
Contributor

$ cargo contract build --output-json
2023-06-10T01:20:10.586663Z  INFO contract_build: No changes in the original wasm at /home/kvin/codes/chain/phala/phat/proven/target/ink/wasm32-unknown-unknown/release/proven.wasm, fingerprint Some(Fingerprint { path: "/home/kvin/codes/chain/phala/phat/proven/target/ink/wasm32-unknown-unknown/release/proven.wasm", hash: [242, 38, 236, 112, 198, 86, 153, 200, 13, 188, 105, 71, 49, 149, 115, 100, 70, 143, 255, 33, 223, 231, 71, 59, 4, 95, 88, 54, 77, 246, 18, 153], modified: SystemTime { tv_sec: 1686358618, tv_nsec: 219799198 }, target: "wasm32-unknown-unknown" }). Skipping Wasm optimization and metadata generation.
{
  "dest_wasm": "/home/kvin/codes/chain/phala/phat/proven/target/ink/proven.wasm",
  "metadata_result": {
    "dest_metadata": "/home/kvin/codes/chain/phala/phat/proven/target/ink/proven.json",
    "dest_bundle": "/home/kvin/codes/chain/phala/phat/proven/target/ink/proven.contract"
  },
  "target_directory": "/home/kvin/codes/chain/phala/phat/proven/target/ink",
  "optimization_result": null,
  "build_mode": "Debug",
  "build_artifact": "All",
  "verbosity": "Quiet"
}

This makes the json parsing failure:

$ cargo contract build --output-json | jq
parse error: Invalid numeric literal at line 1, column 2
thread 'main' panicked at 'failed printing to stdout: Broken pipe (os error 32)', library/std/src/io/stdio.rs:1008:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
@ascjones
Copy link
Collaborator

Do you have RUST_LOG set in your environment? I only get this message when it is set e.g.

image

@kvinwang
Copy link
Contributor Author

kvinwang commented Jun 12, 2023

Do you have RUST_LOG set in your environment? I only get this message when it is set e.g.

Yes, RUST_LOG=info. So, is it on purpose? How about making it configurable, like CARGO_CONTRACT_LOG_TO_STDERR=true?

@ascjones
Copy link
Collaborator

It's not on purpose, it's the default behaviour and hasn't been considered previously. So yes the question is: how do we want it to behave?

Options:

  1. Log to stderr as you suggest, or make it the default, make it configurable
  2. Capture any log output and add it as a field in the json
  3. Leave it as it is and encourage users to disable logging for json output (maybe add a warning message)?

Probably more, but that's a start. Not sure which I prefer at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants