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

[Improvement]: --quiet flag for local runs #1602

Open
jonaro00 opened this issue Jan 31, 2024 · 7 comments
Open

[Improvement]: --quiet flag for local runs #1602

jonaro00 opened this issue Jan 31, 2024 · 7 comments
Assignees
Labels
Contribution Wanted The community is welcome to collaborate on this issue Good First Issue Good for newcomers S-Accepted This will be worked on T-Improvement Improvement or addition to existing features

Comments

@jonaro00
Copy link
Member

jonaro00 commented Jan 31, 2024

Describe the improvement

When starting a local run, there are lots of printouts from both cargo-shuttle and the runtime's startup logic.

A -q / --quiet flag can be added to the run command, that supresses non-error prints in cargo-shuttle. The flag can also be passed on as --quiet to the runtime binary, where it can also be used to supress the lines that are usually printed (the ones that show up with [Runtime] prepended).

A solution that puts the relevant prints inside if-statements should be sufficient.


This issue is open to contribution. Comment if you want to work on it. Feel free to ask for help and guidance here or in our Discord.

@jonaro00 jonaro00 added T-Improvement Improvement or addition to existing features Good First Issue Good for newcomers Contribution Wanted The community is welcome to collaborate on this issue S-Accepted This will be worked on labels Jan 31, 2024
@dhruvdabhi101
Copy link
Contributor

I would like to try this : )

@ccmvn
Copy link

ccmvn commented Feb 12, 2024

I would like to have this feature too, nice idea!

@jonaro00
Copy link
Member Author

@ccmvn Feel free to attempt solving it if you want to :)

@ccmvn
Copy link

ccmvn commented Feb 12, 2024

@ccmvn Feel free to attempt solving it if you want to :)

Unfortunately I'm too busy with my own projects, but it's a cool thing and I would appreciate it if someone else from the community could implement it, because it makes the console cleaner and you don't always need the information that is displayed there

@sourabpramanik
Copy link
Contributor

@jonaro00 this issue is still active? Can I look into this?

@avi9prasad
Copy link

I have gone through this issue if you find my solution useful please let me know . thank you
When running cargo-shuttle, the console often gets cluttered with logs from both cargo-shuttle and the runtime. This makes it harder to focus on key information.

Add a -q or --quiet flag to suppress non-essential logs:

In cargo-shuttle:

Accept the -q / --quiet flag in the run command.
Suppress logs using simple if conditions.
if !quiet {
println!("Info message...");
}
Pass --quiet to the runtime.
Accept --quiet as an argument.
Skip non-error logs (e.g., lines with [Runtime]).

Default:
Show all logs (current behavior).

cargo shuttle run

Quiet Mode:
Suppress non-critical logs.

cargo shuttle run -q

Add verbosity levels to control the amount of logging--

let log_level = if quiet {
"error"
} else if verbosity == 2 {
"trace"
} else if verbosity == 1 {
"debug"
} else {
"info"
};
setup_logging(log_level);
Pass the verbosity level to the runtime binary
Accept the verbosity level (or --quiet) as an argument.
Use a logging library (e.g., env_logger or tracing) to dynamically adjust log output.

if quiet {
println!("Error: Something went wrong.");
} else if verbosity > 0 {
println!("Debug: Detailed runtime info.");
}

Default Behavior---- cargo shuttle run
Quiet Mode----- cargo shuttle run -q
Verbose Modes----cargo shuttle run -v or cargo shuttle run -vv

@jonaro00
Copy link
Member Author

@avi9prasad Those are some great ideas, thanks for moving this forward. I think we can take a much simpler approach now, as logging verbosity has decreased recently:

We currently have a --debug flag that increases logging verbosity in the runtime by setting a lower RUST_LOG level here. This is like what -v would do, but with just one level.

The --quiet flag could do the same thing, but set the level to info,shuttle=error instead, which would suppress basically all shuttle log output.

As for which printouts in cargo-shuttle that could use an if !quiet branch, I'd have to look closer.

Feel free to try adding the RUST_LOG modification if you'd like to play around with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Contribution Wanted The community is welcome to collaborate on this issue Good First Issue Good for newcomers S-Accepted This will be worked on T-Improvement Improvement or addition to existing features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants