< Summary

Information
Class: /home/runner/work/TauriQt/TauriQt/tauri-runtime-qt/src/trace.rs
Assembly: Default
File(s): /home/runner/work/TauriQt/TauriQt/tauri-runtime-qt/src/trace.rs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 35
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

File(s)

/home/runner/work/TauriQt/TauriQt/tauri-runtime-qt/src/trace.rs

#LineLine coverage
 1// SPDX-FileCopyrightText: 2026 Alper Çelik
 2// SPDX-License-Identifier: MIT OR Apache-2.0
 3
 4//! Runtime tracing.
 5//!
 6//! The harnesses (`scripts/smoke.sh`, `scripts/wayland-smoke.sh`,
 7//! `scripts/sway-oracle.sh`) assert on `[tauri-runtime-qt] …` lines, but the
 8//! packaged app is a **release** build — so gating those lines on
 9//! `debug_assertions` meant CI asserted against output that a packaged app never
 10//! prints. Opt in at runtime with `TAURIQT_TRACE=1` instead; the flake's check
 11//! environment sets it, and a debug build behaves as before.
 12
 13/// True when tracing should be emitted: always in a debug build (the previous
 14/// `#[cfg(debug_assertions)]` behaviour, so development is unchanged), and in a
 15/// release build only when `TAURIQT_TRACE` is set — which is what the flake's
 16/// check environment and the harness scripts do.
 17///
 18/// Cached: the value cannot change usefully mid-process and this is consulted on
 19/// hot paths.
 278020pub fn trace_enabled() -> bool {
 2021    static ENABLED: std::sync::LazyLock<bool> = std::sync::LazyLock::new(|| {
 2022        cfg!(debug_assertions) || std::env::var_os("TAURIQT_TRACE").is_some()
 2023    });
 278024    *ENABLED
 278025}
 26
 27/// `eprintln!` when [`trace_enabled`] — no formatting cost when tracing is off.
 28#[macro_export]
 29macro_rules! qtrace {
 30    ($($arg:tt)*) => {
 31        if $crate::trace::trace_enabled() {
 32            eprintln!($($arg)*);
 33        }
 34    };
 35}