mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00

The setup is now as follows: - All user-facing logging goes through `tracing` at an `info` leve. (This excludes messages that go to `stdout`, like the compiled `requirements.txt` file.) - We have `--quiet` and `--verbose` command-line flags to set the tracing filter and format defaults. So if you use `--verbose`, we include timestamps and targets, and filter at `puffin=debug` level. - However, we always respect `RUST_LOG`. So you can override the _filter_ via `RUST_LOG`. For example: the standard setup filters to `puffin=info`, and doesn't show timestamps or targets: <img width="1235" alt="Screen Shot 2023-10-08 at 3 41 22 PM" src="54ca4db6
-c66a-439e-bfa3-b86dee136e45"> If you run with `--verbose`, you get debug logging, but confined to our crates: <img width="1235" alt="Screen Shot 2023-10-08 at 3 41 57 PM" src="c5c1af11
-7f7a-4038-a173-d9eca4c3630b"> If you want verbose logging with _all_ crates, you can add `RUST_LOG=debug`: <img width="1235" alt="Screen Shot 2023-10-08 at 3 42 39 PM" src="0b5191f4
-4db0-4db9-86ba-6f9fa521bcb6"> I think this is a reasonable setup, though we can see how it feels and refine over time. Closes https://github.com/astral-sh/puffin/issues/57.
50 lines
1.2 KiB
Rust
50 lines
1.2 KiB
Rust
use std::process::ExitCode;
|
|
use std::time::Duration;
|
|
|
|
pub(crate) use clean::clean;
|
|
pub(crate) use compile::compile;
|
|
pub(crate) use freeze::freeze;
|
|
pub(crate) use sync::{sync, SyncFlags};
|
|
|
|
mod clean;
|
|
mod compile;
|
|
mod freeze;
|
|
mod sync;
|
|
|
|
#[derive(Copy, Clone)]
|
|
pub(crate) enum ExitStatus {
|
|
/// The command succeeded.
|
|
#[allow(unused)]
|
|
Success,
|
|
|
|
/// The command failed due to an error in the user input.
|
|
#[allow(unused)]
|
|
Failure,
|
|
|
|
/// The command failed with an unexpected error.
|
|
#[allow(unused)]
|
|
Error,
|
|
}
|
|
|
|
impl From<ExitStatus> for ExitCode {
|
|
fn from(status: ExitStatus) -> Self {
|
|
match status {
|
|
ExitStatus::Success => ExitCode::from(0),
|
|
ExitStatus::Failure => ExitCode::from(1),
|
|
ExitStatus::Error => ExitCode::from(2),
|
|
}
|
|
}
|
|
}
|
|
|
|
/// Format a duration as a human-readable string, Cargo-style.
|
|
pub(super) fn elapsed(duration: Duration) -> String {
|
|
let secs = duration.as_secs();
|
|
|
|
if secs >= 60 {
|
|
format!("{}m {:02}s", secs / 60, secs % 60)
|
|
} else if secs > 0 {
|
|
format!("{}.{:02}s", secs, duration.subsec_nanos() / 10_000_000)
|
|
} else {
|
|
format!("{}ms", duration.subsec_millis())
|
|
}
|
|
}
|