Skip to content

Quick Start

darkstar edited this page Oct 3, 2026 · 2 revisions

Quick Start

1️⃣ Build a reporter and emit a diagnostic

use diagprint::{Reporter, Severity};

fn main() -> std::io::Result<()> {
    let reporter = Reporter::builder()
        .application("myapp")
        .min_severity(Severity::Info)
        .build()?;

    let diagnostic = reporter
        .error("Network initialization failed")
        .code("NET-001")
        .cause("failed to open network interface")
        .note("fallback networking is unavailable")
        .help("check interface permissions and driver state");

    reporter.emit(&diagnostic)?;
    Ok(())
}

2️⃣ Point at source

let diagnostic = reporter
    .error("Invalid configuration value")
    .code("CFG-001")
    .label("config.toml", 12, Some(9), Some(5), Some("unsupported value"))
    .secondary_label("defaults.toml", 4, Some(1), Some(7), Some("default declared here"));

label(file, line, column, length, message). Primary and secondary labels stay structurally distinct all the way through rendering and interop.

3️⃣ Send it somewhere else

reporter.emit_github_actions(&diagnostic)?;                    // CI annotations
diagprint::render::SarifRenderer.write_many("target/diagprint.sarif", [&diagnostic])?; // code scanning

4️⃣ Scan a project from the CLI

diagprint scan .                                   # standard profile
diagprint scan . --static                          # executes nothing
diagprint scan . --deep --history .diagprint/history

Tip

Add .diagprint/ to .gitignore so recorded history doesn't dirty later provenance-enabled scans.

Next: Diagnostics & Sources for snapshots and revisions, or Diagnostic Forensics to make use of that history.

← 📥 Installation  ·  🎯 Diagnostics & Sources →

🩺 diagprint

⚡ Start

🧱 Build

📤 Ship

🔧 Fix

🔬 Investigate

🛠️ Project


🌐 Site · 📖 docs.rs · 📦 crates.io

Clone this wiki locally