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

Cargo should use standard logging framework #6751

Open
sanmai-NL opened this issue Mar 15, 2019 · 2 comments
Open

Cargo should use standard logging framework #6751

sanmai-NL opened this issue Mar 15, 2019 · 2 comments
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@sanmai-NL
Copy link

sanmai-NL commented Mar 15, 2019

Cargo can be invoked with a command line interface, as well as non-interactively.

In the latter case, Cargo may e.g. be used as part of a Continuous Integration pipeline.
For that use case, it is important to reduce noise in the build output. Moreover, it is important to see regular timestamps in order to determine where most time is spent in the pipeline.

Cargo writes a line for every dependency package that is builds, which means a lot of information is output that can be considered noise, in this use case. Currently, Cargo can only be made completely silent using the --quiet argument. However, this does not even report errors. This makes this option unattractive to this use case. Cargo also doesn't include timestamps in its output.

Similar to most other long-running command line utilities, Cargo should only use a standard logging framework, configurable by the caller. This would make it easy to:

  • Allow the caller to filter what to log.
  • Include accurate timestamps and other details in log entries.

This change should not be complex in terms of design. In case a concern about aesthetics overrides the previous concerns, and suppose it could not be addressed within the proposed solution, then the solution can be limited to a non-interactive context.

@sanmai-NL sanmai-NL added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Mar 15, 2019
@sanmai-NL
Copy link
Author

The logging framework and profiling info is already available I see in ARCHITECTURE.md. I propose to let it subsume the main user visible console reporting code in https://github.com/rust-lang/cargo/blob/dc83ead224d8622f748f507574e1448a28d8dcc7/src/cargo/core/shell.rs.

@ehuss ehuss added the A-console-output Area: Terminal output, colors, progress bar, etc. label Apr 6, 2020
@epage epage added S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. and removed S-needs-design Status: Needs someone to work further on the design for the feature or fix. NOT YET accepted. labels May 24, 2023
@epage
Copy link
Contributor

epage commented Oct 23, 2023

Currently, Cargo can only be made completely silent using the --quiet argument. However, this does not even report errors. This makes this option unattractive to this use case. Cargo also doesn't include timestamps in its output.

I just checked and warnings and errors are reported with --quiet at this time. Does that change the need for this request?

The logging framework and profiling info is already available I see in ARCHITECTURE.md. I propose to let it subsume the main user visible console reporting code in

I've used logging frameworks in the past for the primary output of my programs and the quality isn't as good. When I tend to shift my focus to the quality of my output, I end up dropping it.

Focusing on specific asks, rather than the implementation:

Allow the caller to filter what to log.
Include accurate timestamps and other details in log entries.

I feel like filtering would be a large ask with limited value, partly from it being hard to get the filters right. I think it would be better to focus on the use cases for filtering to see if there are alternatives. If its just because the output is viewed as noisy generally, then I think that is what we should focus on, rather than on people trying to slice and dice the output.

As for timestamping, the motivation given is to "determine where most time is spent in the pipeline" but that won't really help unless we say when things start, and not just when they end. As an alternative, we now have --timings; you could run that and artifact it. When you really just want timestamps for each line, an approach I've taken before is to write wrapper programs that monitor output and do things like add timing information or produce JUnit output.

@epage epage added the S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. label Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-console-output Area: Terminal output, colors, progress bar, etc. C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

3 participants