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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//! Logging toggle for the `CoW` SDK, ported from `utils/log.ts`.
//!
//! Uses a global [`AtomicBool`] flag to gate SDK-level trace output through
//! the `tracing` crate. When disabled (the default), `tracing` events emitted
//! at `info` level or below from `cow_rs` are effectively suppressed unless
//! the caller installs their own subscriber.
use ;
/// Global flag that gates SDK trace output.
static LOG_ENABLED: AtomicBool = new;
/// Enable or disable SDK-level logging.
///
/// When set to `true`, the SDK will emit `tracing` events at `info` level
/// for major operations (quote requests, signing, posting, etc.).
///
/// The flag is stored in a global [`AtomicBool`] — changes take effect
/// immediately and are visible from all threads.
///
/// Mirrors `enableLogging(enabled)` from the `TypeScript` SDK.
///
/// # Parameters
///
/// * `enabled` — `true` to enable SDK logging, `false` to suppress it.
///
/// # Example
///
/// ```
/// use cow_rs::common::logging::enable_logging;
///
/// enable_logging(true);
/// assert!(cow_rs::common::logging::is_logging_enabled());
/// enable_logging(false);
/// assert!(!cow_rs::common::logging::is_logging_enabled());
/// ```
/// Returns `true` if SDK logging is currently enabled.
///
/// # Returns
///
/// The current value of the global logging flag.
///
/// # Example
///
/// ```
/// use cow_rs::common::logging::{enable_logging, is_logging_enabled};
///
/// enable_logging(false);
/// assert!(!is_logging_enabled());
/// ```
/// Log a message at `info` level if SDK logging is enabled.
///
/// When logging is disabled (the default), this function is a no-op.
/// When enabled, the message is emitted via `tracing::info!` with target
/// `"cow_sdk"`.
///
/// Mirrors the `TypeScript` `log(text)` function which prefixes messages
/// with `[COW SDK]`. In Rust we use the `tracing` crate's structured
/// logging instead.
///
/// # Parameters
///
/// * `text` — the message to log.
///
/// # Example
///
/// ```
/// use cow_rs::common::logging::{enable_logging, sdk_log};
///
/// enable_logging(true);
/// sdk_log("getting quote for WETH → USDC");
/// ```