quantrs/macros/
logging_macros.rs

1//! This module contains the logging macros that are used to log messages to the console.
2//! The following macros are available:
3//! - `log_info!` - Log an info message.
4//! - `log_error!` - Log an error message.
5//! - `log_warn!` - Log a warning message.
6//! - `log_debug!` - Log a debug message.
7//! - `log_trace!` - Log a trace message.
8//!
9//! # Examples
10//!
11//! ```rust
12//! use quantrs::log_info;
13//!
14//! log_info!("This is an info message");
15//! ```
16//!
17//! The output will look like this:
18//! ```text
19//! [INFO][2021-08-29T14:00:00.000000000]: This is an info message
20//! ```
21
22/// Log an info message.
23#[macro_export]
24macro_rules! log_info {
25    ($msg:expr) => {
26        println!("[INFO][{}]: {}", chrono::Local::now(), $msg);
27    };
28}
29
30/// Log an error message.
31#[macro_export]
32macro_rules! log_error {
33    ($msg:expr) => {
34        println!("[ERROR][{}]: {}", chrono::Local::now(), $msg);
35    };
36}
37
38/// Log a warning message.
39#[macro_export]
40macro_rules! log_warn {
41    ($msg:expr) => {
42        println!("[WARN][{}]: {}", chrono::Local::now(), $msg);
43    };
44}
45
46/// Log a debug message.
47#[macro_export]
48macro_rules! log_debug {
49    ($msg:expr) => {
50        println!("[DEBUG][{}]: {}", chrono::Local::now(), $msg);
51    };
52}
53
54/// Log a trace message.
55#[macro_export]
56macro_rules! log_trace {
57    ($msg:expr) => {
58        println!("[TRACE][{}]: {}", chrono::Local::now(), $msg);
59    };
60}