qt_core/
q_message_logger_macros.rs

1/// Creates a `QMessageLogger` with attached information about current file, line, and module.
2#[macro_export]
3macro_rules! q_message_logger {
4    () => {
5        $crate::QMessageLogger::new_3a(
6            ::std::ffi::CStr::from_bytes_with_nul_unchecked(concat!(file!(), "\0").as_bytes())
7                .as_ptr(),
8            line!() as i32,
9            ::std::ffi::CStr::from_bytes_with_nul_unchecked(
10                concat!(module_path!(), "\0").as_bytes(),
11            )
12            .as_ptr(),
13        )
14    };
15}
16
17/// Creates a `QDebug` that logs a debug message
18/// with attached information about current file, line, and module.
19///
20/// This is similar to `qDebug()` C++ macro.
21#[macro_export]
22macro_rules! q_debug {
23    () => {
24        &$crate::q_message_logger!().debug_0a()
25    };
26}
27
28/// Creates a `QDebug` that logs an informational message
29/// with attached information about current file, line, and module.
30///
31/// This is similar to `qInfo()` C++ macro.
32#[macro_export]
33macro_rules! q_info {
34    () => {
35        &$crate::q_message_logger!().info_0a()
36    };
37}
38
39/// Creates a `QDebug` that logs a warning message
40/// with attached information about current file, line, and module.
41///
42/// This is similar to `qWarning()` C++ macro.
43#[macro_export]
44macro_rules! q_warning {
45    () => {
46        &$crate::q_message_logger!().warning_0a()
47    };
48}
49
50/// Creates a `QDebug` that logs a critical message
51/// with attached information about current file, line, and module.
52///
53/// This is similar to `qCritical()` C++ macro.
54#[macro_export]
55macro_rules! q_critical {
56    () => {
57        &$crate::q_message_logger!().critical_0a()
58    };
59}