ankurah_core/util/
mod.rs

1pub mod expand_states;
2pub mod iterable;
3pub mod ivec;
4pub mod ready_chunks;
5pub mod safemap;
6pub mod safeset;
7pub use iterable::Iterable;
8pub use ivec::IVec;
9
10/// Formats an action log with consistent styling.
11/// First argument is always a "thing" that performed the action (in bold blue)
12/// Second argument is the action name (in green)
13/// Remaining arguments are formatted as additional context (dimmed)
14#[macro_export]
15macro_rules! action_info {
16    // Thing + action
17    ($thing:expr, $action:expr) => {
18        tracing::info!("\x1b[1;34m{}\x1b[0m → \x1b[32m{}\x1b[0m", $thing, $action)
19    };
20    // Thing + action + args
21    ($thing:expr, $action:expr, $($arg:expr),+) => {
22        tracing::info!("\x1b[1;34m{}\x1b[0m → \x1b[32m{}\x1b[0m \x1b[2m{}\x1b[0m", $thing, $action, format!("{}", format_args!($($arg),+)))
23    };
24}
25
26#[macro_export]
27macro_rules! action_debug {
28    // Thing + action
29    ($thing:expr, $action:expr) => {
30        tracing::debug!("\x1b[1;34m{}\x1b[0m → \x1b[32m{}\x1b[0m", $thing, $action)
31    };
32    // Thing + action + args
33    ($thing:expr, $action:expr, $($arg:expr),+) => {
34        tracing::debug!("\x1b[1;34m{}\x1b[0m → \x1b[32m{}\x1b[0m \x1b[2m{}\x1b[0m", $thing, $action, format!("{}", format_args!($($arg),+)))
35    };
36}
37
38#[macro_export]
39macro_rules! action_warn {
40    // Thing + action
41    ($thing:expr, $action:expr) => {
42        tracing::warn!("\x1b[1;34m{}\x1b[0m → \x1b[32m{}\x1b[0m", $thing, $action)
43    };
44    // Thing + action + args
45    ($thing:expr, $action:expr, $($arg:expr),+) => {
46        tracing::warn!("\x1b[1;34m{}\x1b[0m → \x1b[32m{}\x1b[0m \x1b[2m{}\x1b[0m", $thing, $action, format!("{}", format_args!($($arg),+)))
47    };
48}
49
50#[macro_export]
51macro_rules! action_error {
52    // Thing + action
53    ($thing:expr, $action:expr) => {
54        tracing::error!("\x1b[1;34m{}\x1b[0m → \x1b[32m{}\x1b[0m", $thing, $action)
55    };
56    // Thing + action + args
57    ($thing:expr, $action:expr, $($arg:expr),+) => {
58        tracing::error!("\x1b[1;34m{}\x1b[0m → \x1b[32m{}\x1b[0m \x1b[2m{}\x1b[0m", $thing, $action, format!("{}", format_args!($($arg),+)))
59    };
60}
61
62/// Formats a notice log with consistent styling.
63/// The message is displayed in bold yellow to make it stand out.
64#[macro_export]
65macro_rules! notice_info {
66    ($($arg:tt)*) => {
67        tracing::info!("\x1b[1;33m{}\x1b[0m", format!($($arg)*))
68    };
69}