Skip to main content

gpui_navigator/
logging.rs

1//! Logging abstraction layer
2//!
3//! This module provides logging macros that work with both `log` and `tracing` crates.
4//!
5//! # Features
6//!
7//! - `log` (default) - Uses the standard `log` crate
8//! - `tracing` - Uses the `tracing` crate for structured logging
9//!
10//! Choose one feature at compile time. They are mutually exclusive.
11//!
12//! # Usage
13//!
14//! ```ignore
15//! use gpui_navigator::{trace_log, debug_log, info_log};
16//!
17//! trace_log!("Entering function");
18//! debug_log!("Navigating to route: {}", path);
19//! info_log!("Navigation complete");
20//! ```
21
22/// Trace-level logging
23///
24/// Logs detailed information for debugging purposes.
25#[macro_export]
26macro_rules! trace_log {
27    ($($arg:tt)*) => {
28        #[cfg(feature = "tracing")]
29        ::tracing::trace!($($arg)*);
30        #[cfg(feature = "log")]
31        ::log::trace!($($arg)*);
32    };
33}
34
35/// Debug-level logging
36///
37/// Logs information useful for debugging.
38#[macro_export]
39macro_rules! debug_log {
40    ($($arg:tt)*) => {
41        #[cfg(feature = "tracing")]
42        ::tracing::debug!($($arg)*);
43        #[cfg(feature = "log")]
44        ::log::debug!($($arg)*);
45    };
46}
47
48/// Info-level logging
49///
50/// Logs general informational messages.
51#[macro_export]
52macro_rules! info_log {
53    ($($arg:tt)*) => {
54        #[cfg(feature = "tracing")]
55        ::tracing::info!($($arg)*);
56        #[cfg(feature = "log")]
57        ::log::info!($($arg)*);
58    };
59}
60
61/// Warn-level logging
62///
63/// Logs warning messages.
64#[macro_export]
65macro_rules! warn_log {
66    ($($arg:tt)*) => {
67        #[cfg(feature = "tracing")]
68        ::tracing::warn!($($arg)*);
69        #[cfg(feature = "log")]
70        ::log::warn!($($arg)*);
71    };
72}
73
74/// Error-level logging
75///
76/// Logs error messages.
77#[macro_export]
78macro_rules! error_log {
79    ($($arg:tt)*) => {
80        #[cfg(feature = "tracing")]
81        ::tracing::error!($($arg)*);
82        #[cfg(feature = "log")]
83        ::log::error!($($arg)*);
84    };
85}