Skip to content

Commit

Permalink
Merge c6d357a into 4a4e511
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj authored Jul 12, 2023
2 parents 4a4e511 + c6d357a commit 41d5034
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
34 changes: 34 additions & 0 deletions crates/turbopack-core/src/diagnostics/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use anyhow::Result;
use turbo_tasks::{emit, primitives::StringVc};

/// An arbitrary metadata payload can be used to analyze, diagnose
/// Turbopack's behavior.
#[turbo_tasks::value_trait]
pub trait Diagnostics {
// [TODO]: These are subject to change; not finalized yet.
fn category(&self) -> StringVc;
fn key(&self) -> StringVc;
fn value(&self) -> StringVc;
}

impl DiagnosticsVc {
pub fn emit(self) {
emit(self);
}

pub async fn peek_diagnostics_with_path<T: turbo_tasks::CollectiblesSource + Copy>(
source: T,
) -> Result<CapturedDiagnosticsVc> {
Ok(CapturedDiagnosticsVc::cell(CapturedDiagnostics {
diagnostics: source.peek_collectibles().strongly_consistent().await?,
}))
}
}

/// A list of diagnostics captured with
/// [`DiagnosticsVc::peek_diagnostics_with_path`] and
#[derive(Debug)]
#[turbo_tasks::value]
pub struct CapturedDiagnostics {
pub diagnostics: auto_hash_map::AutoSet<DiagnosticsVc>,
}
1 change: 1 addition & 0 deletions crates/turbopack-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub mod chunk;
pub mod code_builder;
pub mod compile_time_info;
pub mod context;
pub mod diagnostics;
pub mod environment;
pub mod error;
pub mod file_source;
Expand Down

0 comments on commit 41d5034

Please sign in to comment.