Skip to content

Conversation

@cbgbt
Copy link
Contributor

@cbgbt cbgbt commented Dec 4, 2025

Add a --quiet/-q flag that suppresses informational messages while preserving warnings and errors.

Changes:

  • Add --quiet flag to CLI arguments
  • Thread quiet parameter through build and make commands
  • Conditionally add --quiet to cargo-make invocations
  • Set TWOLITER_QUIET env var for embedded tools
  • Adjust pubsys/testsys log levels based on quiet mode
  • Update init_logger to respect quiet flag

In quiet mode:

  • Suppresses cargo-make INFO messages
  • Suppresses twoliter INFO logs
  • Sets embedded tool log levels to warn
  • Still shows all warnings and errors
  • Completely silent on successful builds

Normal mode behavior is unchanged.

Testing done:

  • Ensure error messages still look right under various failure modes in --quiet mode
    See this gist for a before/after comparison.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@swagatbora90
Copy link
Contributor

Why not just allow users to set the log level directly?

@cbgbt
Copy link
Contributor Author

cbgbt commented Dec 5, 2025

@swagatbora90 I think the log level can already be controlled. What I really want here is to suppress or dramatically reduce the amount of "informational" stdout printing, which isn't all routed through a logging module.

In my mind, the stdout printing is meant for user consumption and the logging is more of a diagnostic output.

@cbgbt cbgbt force-pushed the quiet-mode branch 2 times, most recently from 7471d2b to 104125e Compare December 16, 2025 19:03
Add a --quiet/-q flag that suppresses informational messages while
preserving warnings and errors.

Changes:
- Add --quiet flag to CLI arguments
- Thread quiet parameter through build and make commands
- Conditionally add --quiet to cargo-make invocations
- Set TWOLITER_QUIET env var for embedded tools
- Adjust pubsys/testsys log levels based on quiet mode
- Update init_logger to respect quiet flag

In quiet mode:
- Suppresses cargo-make INFO messages
- Suppresses twoliter INFO logs
- Sets embedded tool log levels to warn
- Still shows all warnings and errors
- Completely silent on successful builds

Normal mode behavior is unchanged.
@cbgbt cbgbt marked this pull request as ready for review December 16, 2025 20:10
PUBLISH_REPO = "default"

PUBLISH_LOG_LEVEL = "info"
PUBLISH_LOG_LEVEL = { script = ["if [ -n \"${TWOLITER_QUIET}\" ]; then echo warn; else echo info; fi"], condition = { env_not_set = ["PUBLISH_LOG_LEVEL"] } }
Copy link

Choose a reason for hiding this comment

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

-n checks if $TWOLITER_QUIET exists. But the implementation sets "1" or "0" for it. Should we check the value here directly instead?

.env("TWOLITER_QUIET", if global_opts.quiet { "1" } else { "0" })
.makefile(makefile_path)
.project_dir(project.project_dir())
.quiet(global_opts.quiet)
Copy link

Choose a reason for hiding this comment

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

Q - looking at the code, it seems that the CargoMake.quiet field is not really used? Only the env var was used.

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.

4 participants