Skip to main content

Module DevLog

Module DevLog 

Source
Expand description

Tag-filtered development logging (Trace env var). Must be declared before WindServiceHandlers so the dev_log! macro is available.

§DevLog - Tag-filtered development logging

Tag-gated logging used across Mountain. Controlled by the Trace env var: Trace=vfs,ipc for selective tags, Trace=all for everything, Trace=short for the everything-but-firehose preset (path aliasing + dedupe). Mirror to a session log file when Record=1 (or when Trace is set in a debug build).

Layout: every public Fn/Struct lives in its own sibling file. The two macros (dev_log!, otel_span!) live here so #[macro_export] puts them at the crate root and the callsite spelling stays dev_log!("ipc", "…").

Modules§

AliasPath
Replace the long Tauri app-data prefix with $APP so Trace=short lines stay readable.
AppDataPrefix
Resolve the Tauri app-data prefix for THIS profile so logs and aliasing pick the right ~/Library/Application Support/ land.editor.*.mountain directory. The detection walks the Application Support tree, prefers a strict suffix match against the binary signature, falls back to the first *.mountain candidate so a mismatch still produces a usable path.
DebugOnce
Emit a tagged dev-log line exactly once per process, keyed on Key. Subsequent calls with the same key are dropped from the console; the file sink still records the first occurrence so post-mortems show every probe path that fired.
DedupState
Consecutive-duplicate suppression buffer used by the dev_log! macro under Trace=short. Holds the last logged key + a repeat count; the macro flushes a (xN) tail when the key changes.
EmitOTLPSpan
Fire-and-forget OTLP span exporter. Sends a single resourceSpans payload over plain HTTP to the collector at OTLPEndpoint (default 127.0.0.1:4318, configurable via .env.Land.PostHog). Stops trying after the first failure (OTLP_AVAILABLE flips to false) so a missing collector doesn’t tax every IPC call. Release builds are compiled out via cfg!(debug_assertions). Honors the Capture master telemetry kill switch and the per-pipe OTLPEnabled toggle.
FlushDedup
Flush the consecutive-duplicate buffer - emits a (xN) tail line if the pending count is greater than 1, then clears.
InitEager
Force the file sink to initialise before the first dev_log! so a panic on the boot path still produces a header line + opt-in path. Harmless to call multiple times.
IsBenignEnoent
Recognise known-optional probe paths so stat ENOENT lines for them downgrade to debug-once instead of full error noise. The list is the union of:
IsEnabled
Tag-resolution helper. Reads Trace once into a static list, then matches against four rules per call:
IsShort
true when Trace=short is set - enables path aliasing and consecutive-duplicate compression in dev_log!.
NowNano
Wall-clock nanoseconds since UNIX epoch. Used as the start tick for OTLP spans and per-IPC latency measurements.
SessionTimestamp
Local-time session timestamp (%Y%m%dT%H%M%S) cached once per process. Must agree with WindServiceHandlers::nativeHost:getEnvironmentPaths so the Mountain dev log and VS Code’s window<N>/output_* log land in the same session directory.
WriteToFile
Append a single formatted line to the session’s Mountain.dev.log. The file sink is lazy: opens on first call, no-ops if Record=0 or the directory cannot be created. Flushes per line so tail -f shows live output.