You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(logging): unify debug logging into a single stderr dbg_log! macro (#1145)
Debug logging was split two ways. ~19 call sites hand-rolled
`if crate::DEBUG.load(..) { eprintln!("[DBG] ..") }` (stderr, no timestamp,
repeated boilerplate), while the short-lived `log_dbg` helper rendered
`{ts} DBG` but routed through `cprintln!` — i.e. **stdout**. Any unguarded
`log_dbg` under `--debug` therefore interleaved a DBG line into JSON / JSONL /
SARIF output on stdout (the v3.1 TLS-insecure diagnostic was exactly such a
site).
Introduce `crate::dbg_log!` (src/utils/log.rs): gates on `crate::DEBUG`,
writes to **stderr** via `ceprintln!` (so structured stdout is never
polluted and ANSI is stripped under `--no-color`/`NO_COLOR`), and renders the
`{ts} DBG <msg>` format. The macro is lazy — the message is only formatted
when `--debug` is active — so it stays cheap in hot per-request paths
(reflection / scanning) where a function taking `&format!(..)` would not.
- Migrate all `[DBG]` eprintln sites (payload, preflight, discovery,
parameter_analysis, oob poller, xss_blind, check_reflection, scanning,
waf) to `dbg_log!`, dropping the per-site DEBUG guard and `[DBG]` prefix.
- Remove `log_dbg` from cmd::scan::logging; its callers (TLS diagnostic,
reqs-sent/estimated) now use `dbg_log!`.
Verified: `dalfox url --url https://… --format json --debug` keeps stdout
valid JSON with zero DBG lines; the `{ts} DBG` line lands on stderr and
strips ANSI under NO_COLOR. clippy clean, 1756 lib tests pass.
0 commit comments