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

refactor!: logging #242

Merged
merged 2 commits into from
Feb 13, 2025
Merged

refactor!: logging #242

merged 2 commits into from
Feb 13, 2025

Conversation

beeb
Copy link
Collaborator

@beeb beeb commented Jan 19, 2025

This PR aims to further decouple the core crate from the CLI stuff, by removing the cli feature flag and dependency on cliclack.
To achieve this, some refactoring is in order, so that all client-facing logging is done in the soldeer-commands crate.

This PR adds verbose and quiet flags to the soldeer_commands crate and a verbose parameter to the soldeer_commands::run function. If any verbosity is specified, the tool will skip the usage of cliclack for pretty-printing progress and use structured logging instead.

soldeer install --clean -vv
[2025-02-05T22:02:33Z INFO  soldeer_core::install] dependency is missing, installing dep=forge-std~1
[2025-02-05T22:02:33Z INFO  soldeer_core::install] dependency is missing, installing dep=@uniswap-permit2~1.0.0
[2025-02-05T22:02:33Z INFO  soldeer_core::install] dependency is missing, installing dep=solady~0.0.228
[2025-02-05T22:02:33Z INFO  soldeer_core::install] dependency is missing, installing dep=@openzeppelin-contracts~5

In the CLI help:

Options:
  -v, --verbose...
          Use structured logging and increase verbosity

          Pass multiple times to increase the logging level (e.g. -v, -vv, -vvv).
          If omitted, then a pretty TUI output will be used.
          Otherwise:
          - 1 (-v): print logs with level error and warning
          - 2 (-vv): print logs with level info
          - 3 (-vvv): print logs with level debug
          - 4 (-vvvv): print logs with level trace


  -q, --quiet...
          Disable logs and output, or reduce verbosity

Breaking Changes

  • the cli and cliclack feature flags on soldeer_core have been removed
  • soldeer_core::install::PROGRESS_TEMPLATE has been removed
  • soldeer_commands::ConfigLocation now wraps the soldeer_core::config::ConfigLocation
  • soldeer_commands::run now takes a new verbose parameter
    • Verbosity::default() or Verbose::new(0, 0) uses cliclack
    • Verbosity::new(1, 0) prints errors and warnings
    • Verbosity::new(2, 0) prints info
    • Verbosity::new(3, 0) prints debug
    • Verbosity::new(4, 0) prints trace
    • Verbosity::new(0, 1) prints nothing (if quiet is larger than verbose)
  • soldeer_core::install::Progress has been replaced with soldeer_core::install::InstallMonitoring and soldeer_core::install::InstallProgress

Closes #208

@beeb beeb marked this pull request as draft January 19, 2025 14:21
@beeb beeb force-pushed the decouple-logging-cli branch 7 times, most recently from efe7926 to edff51f Compare February 5, 2025 21:57
feat: add logging to update module

refactor: remove useless utility to read a file

feat: add logging to utils

feat: verbose flag

feat: support RUST_LOG

fix: disable tui
@beeb beeb force-pushed the decouple-logging-cli branch from edff51f to 7b15dc2 Compare February 5, 2025 21:58
@beeb beeb self-assigned this Feb 5, 2025
@beeb beeb marked this pull request as ready for review February 5, 2025 22:05
@beeb beeb requested a review from mario-eth February 5, 2025 22:05
@kubkon
Copy link
Contributor

kubkon commented Feb 13, 2025

FWIW I would love to see this landed. Having this in would have made debugging an issue like #246 much, much simpler.

@beeb beeb merged commit 355a3e9 into mario-eth:main Feb 13, 2025
8 checks passed
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.

Use the log crate for logging output if the cli flag is disabled
3 participants