1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//! Structured logging and profiling via tracing.
//!
//! - [`init`] / [`init_with_level`] — standard log output controlled by `PRAVASH_LOG`
//! - [`init_profiling`] — chrome://tracing JSON output for flame graph analysis
//!
//! All pravash operations emit `trace_span!` events. With profiling enabled,
//! these produce a `trace-{timestamp}.json` file that can be loaded into
//! `chrome://tracing` or processed by tools like `inferno`.
/// Initialize logging with default "info" level.
/// Initialize logging with a custom default level.
/// Respects the `PRAVASH_LOG` env var (e.g., `PRAVASH_LOG=trace`).
/// Initialize profiling with chrome://tracing JSON output.
///
/// Returns a [`FlushGuard`](tracing_chrome::FlushGuard) that must be held
/// alive for the duration of profiling. When dropped, it flushes and closes
/// the trace file.
///
/// The trace file is written to the current directory as `trace-{pid}.json`.
///
/// # Usage
///
/// ```ignore
/// let _guard = pravash::logging::init_profiling();
/// // ... run simulation ...
/// // guard dropped here, trace file flushed
/// ```