Improve logging

This commit is contained in:
Aleksey Kladov 2020-08-25 11:27:22 +02:00
parent b4bc346498
commit 3a72afed8c
5 changed files with 32 additions and 14 deletions

View file

@ -6,6 +6,7 @@ mod sysroot;
mod cfg_flag;
use std::{
fmt,
fs::{self, read_dir, ReadDir},
io,
process::Command,
@ -27,7 +28,7 @@ pub use crate::{
pub use proc_macro_api::ProcMacroClient;
#[derive(Debug, Clone, Eq, PartialEq)]
#[derive(Clone, Eq, PartialEq)]
pub enum ProjectWorkspace {
/// Project workspace was discovered by running `cargo metadata` and `rustc --print sysroot`.
Cargo { cargo: CargoWorkspace, sysroot: Sysroot },
@ -35,6 +36,19 @@ pub enum ProjectWorkspace {
Json { project: ProjectJson },
}
impl fmt::Debug for ProjectWorkspace {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
ProjectWorkspace::Cargo { cargo, .. } => {
f.debug_struct("Cargo").field("n_packages", &cargo.packages().len()).finish()
}
ProjectWorkspace::Json { project } => {
f.debug_struct("Json").field("n_crates", &project.crates.len()).finish()
}
}
}
}
/// `PackageRoot` describes a package root folder.
/// Which may be an external dependency, or a member of
/// the current workspace.