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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//! SolTrace — structured, Borsh-serialized Anchor events for Solana programs.
//!
//! ## Why this exists
//!
//! Solana programs rely on `msg!` for observability, but `msg!` performs string
//! formatting on-chain. For a swap instruction logging an amount and a pubkey,
//! `msg!` costs roughly 11,000 CU. SolTrace replaces that with a single
//! `emit!` call over a Borsh-serialized struct, cutting the same log entry to
//! ~781 CU — a 92.96% reduction.
//!
//! The emitted events are standard Anchor events, visible as `Program data:`
//! entries in transaction metadata and decodable by any Borsh-aware client.
//!
//! ## Quick start
//!
//! ```rust,ignore
//! use anchor_lang::prelude::*;
//! use soltrace::{sol_info, sol_warn};
//!
//! #[derive(AnchorSerialize, AnchorDeserialize)]
//! pub struct SwapExecuted {
//! pub amount: u64,
//! pub user: Pubkey,
//! }
//!
//! pub fn swap(ctx: Context<Swap>, amount: u64) -> Result<()> {
//! sol_info!("swap_executed", SwapExecuted {
//! amount,
//! user: ctx.accounts.user.key(),
//! });
//! Ok(())
//! }
//! ```
//!
//! ## Feature flags
//!
//! | Flag | Default | Effect |
//! |------|---------|--------|
//! | `devnet-only` | off | Compiles out all `emit!` calls. Enable in mainnet builds. |
//! | `no-entrypoint` | off | Passes through to `anchor-lang/no-entrypoint`. |
pub use SolTraceEvent;
pub use LogLevel;
/// Semi-private API used by the `sol_log!` macro family.
///
/// Items in this module are not covered by semver stability guarantees.
/// Do not call them directly.