Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

736 B
Raw Blame
/// Logs at `info!` level with "CHATTY: " prefix when enabled, otherwise `debug!` level.
/// Accepts the same syntax as tracing macros: `debug_or_info!(flag, field=?value, "message")`
#[macro_export]
macro_rules! debug_or_info {
    ($enabled:expr, $($args:tt)+) => {
        $crate::debug_or_info!(@parse $enabled, [] $($args)+)
    };

    (@parse $enabled:expr, [$($fields:tt)*] $msg:literal) => {
        if $enabled {
            ::tracing::info!($($fields)* concat!("CHATTY: ", $msg));
        } else {
            ::tracing::debug!($($fields)* $msg);
        }
    };

    (@parse $enabled:expr, [$($fields:tt)*] $next:tt $($rest:tt)+) => {
        $crate::debug_or_info!(@parse $enabled, [$($fields)* $next] $($rest)+)
    };
}