Skip to content

Commit

Permalink
Merge pull request torvalds#452 from wedsonaf/pr_debug
Browse files Browse the repository at this point in the history
rust: add `pr_debug`.
  • Loading branch information
ojeda authored Jul 22, 2021
2 parents bc33ea8 + 4010fe9 commit 1ce1631
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rust/kernel/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub use macros::{module, module_misc_device};

pub use super::build_assert;

pub use super::{pr_alert, pr_crit, pr_emerg, pr_err, pr_info, pr_notice, pr_warn};
pub use super::{pr_alert, pr_crit, pr_debug, pr_emerg, pr_err, pr_info, pr_notice, pr_warn};

pub use super::static_assert;

Expand Down
29 changes: 29 additions & 0 deletions rust/kernel/print.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,35 @@ macro_rules! pr_info (
)
);

/// Prints a debug-level message (level 7).
///
/// Use this level for debug messages.
///
/// Equivalent to the kernel's [`pr_debug`] macro, except that it doesn't support dynamic debug
/// yet.
///
/// Mimics the interface of [`std::print!`]. See [`core::fmt`] and
/// [`alloc::format!`] for information about the formatting syntax.
///
/// [`pr_debug`]: https://www.kernel.org/doc/html/latest/core-api/printk-basics.html#c.pr_debug
/// [`std::print!`]: https://doc.rust-lang.org/std/macro.print.html
///
/// # Examples
///
/// ```
/// # use kernel::prelude::*;
/// pr_debug!("hello {}\n", "there");
/// ```
#[macro_export]
#[doc(alias = "print")]
macro_rules! pr_debug (
($($arg:tt)*) => (
if cfg!(debug_assertions) {
$crate::print_macro!($crate::print::format_strings::DEBUG, false, $($arg)*)
}
)
);

/// Continues a previous log message in the same line.
///
/// Use only when continuing a previous `pr_*!` macro (e.g. [`pr_info!`]).
Expand Down

0 comments on commit 1ce1631

Please sign in to comment.