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

[cli] change default logging level for Sui CLI (Client, Move, Keytool) #13533

Merged
merged 1 commit into from Aug 29, 2023

Conversation

stefan-mysten
Copy link
Contributor

@stefan-mysten stefan-mysten commented Aug 29, 2023

Description

This PR changes the default logging level for Sui CLI (Client, Move, Keytool) from info to error. The logging level can be overwritten by setting the RUST_LOG env variable.

Test Plan

All tests pass, manual visual test using the Sui binary (no info logs are shown when issuing commands).


If your changes are not user-facing and not a breaking change, you can skip the following section. Otherwise, please indicate what changed, and then add to the Release Notes section as highlighted during the release process.

Type of Change (Check all that apply)

  • protocol change
  • user-visible impact
  • breaking change for a client SDKs
  • breaking change for FNs (FN binary must upgrade)
  • breaking change for validators or node operators (must upgrade binaries)
  • breaking change for on-chain data layout
  • necessitate either a data wipe or data migration

Release notes

This PR changes the default logging level for Sui CLI (Client, Move, Keytool) from info to error. The logging level can be overwritten by setting the RUST_LOG env variable.

@vercel
Copy link

vercel bot commented Aug 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mysten-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 29, 2023 4:32pm
sui-typescript-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 29, 2023 4:32pm
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
explorer ⬜️ Ignored (Inspect) Visit Preview Aug 29, 2023 4:32pm
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview Aug 29, 2023 4:32pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview Aug 29, 2023 4:32pm

@@ -273,6 +273,10 @@ impl TelemetryConfig {
self.tokio_console = true;
}

if let Ok(log_level) = env::var("RUST_LOG") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an interesting find that RUST_LOG is not being read here. Couple of notes though:

  • RUST_LOG may not just be a log level, it could also contain per-module levels/filters so we should check whether this does the right thing given that kind of input.
    • (Note, that I believe we use tracing-rs, instead of env_logger, but I couldn't find its docs on how it interprets RUST_LOG and AFAICT, it is compatible).
  • From what I could tell, logging was behaving badly even when RUST_LOG was not set at all, which this change should not affect. Were you able to reproduce that behaviour, and if so, do these changes fix it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section should be removed, RUST_LOG is already being handled elsewhere on line 304-305

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what happens when I code late at night (my brain stops functioning). I removed this because indeed was not needed.

From what I could tell, logging was behaving badly even when RUST_LOG was not set at all, which this change should not affect. Were you able to reproduce that behaviour, and if so, do these changes fix it?
That's a good point. I built the binaries without this change and gave it a try. The thing is that if one sets RUST_LOG, all commands will follow that log level. For example, sui start / genesis/ will all use the RUST_LOG, but so is keytool, move, client etc. It looks like in some commands we might want to use info! (e.g., in keytool) for easier visual debugging. Therefore, I think probably setting the log level for some commands to error is a good thing, and then the user can overwrite by setting the variable.

For some of the commands (sui start, network, genesis, etc), we should keep info level.

crates/sui/src/main.rs Outdated Show resolved Hide resolved
@@ -273,6 +273,10 @@ impl TelemetryConfig {
self.tokio_console = true;
}

if let Ok(log_level) = env::var("RUST_LOG") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section should be removed, RUST_LOG is already being handled elsewhere on line 304-305

…nfo. This can be overwritten by setting up a RUST_LOG env variable
@stefan-mysten stefan-mysten merged commit 59eeeae into MystenLabs:main Aug 29, 2023
36 checks passed
@stefan-mysten stefan-mysten deleted the fix_logging_for_cli branch August 29, 2023 17:05
randall-Mysten pushed a commit that referenced this pull request Sep 6, 2023
#13533)

## Description 

This PR changes the default logging level for Sui CLI (Client, Move,
Keytool) from info to error. The logging level can be overwritten by
setting the RUST_LOG env variable.

## Test Plan 

All tests pass, manual visual test using the Sui binary (no info logs
are shown when issuing commands).

---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [ ] protocol change
- [x] user-visible impact
- [ ] breaking change for a client SDKs
- [ ] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
This PR changes the default logging level for Sui CLI (Client, Move,
Keytool) from info to error. The logging level can be overwritten by
setting the RUST_LOG env variable.
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

Successfully merging this pull request may close these issues.

None yet

4 participants