1 // SPDX-License-Identifier: GPL-2.0
3 //! Rust printing macros sample.
6 use kernel::prelude::*;
11 author: "Rust for Linux Contributors",
12 description: "Rust printing macros sample",
18 impl kernel::Module for RustPrint {
19 fn init(_module: &'static ThisModule) -> Result<Self> {
20 pr_info!("Rust printing macros sample (init)\n");
22 pr_emerg!("Emergency message (level 0) without args\n");
23 pr_alert!("Alert message (level 1) without args\n");
24 pr_crit!("Critical message (level 2) without args\n");
25 pr_err!("Error message (level 3) without args\n");
26 pr_warn!("Warning message (level 4) without args\n");
27 pr_notice!("Notice message (level 5) without args\n");
28 pr_info!("Info message (level 6) without args\n");
30 pr_info!("A line that");
31 pr_cont!(" is continued");
32 pr_cont!(" without args\n");
34 pr_emerg!("{} message (level {}) with args\n", "Emergency", 0);
35 pr_alert!("{} message (level {}) with args\n", "Alert", 1);
36 pr_crit!("{} message (level {}) with args\n", "Critical", 2);
37 pr_err!("{} message (level {}) with args\n", "Error", 3);
38 pr_warn!("{} message (level {}) with args\n", "Warning", 4);
39 pr_notice!("{} message (level {}) with args\n", "Notice", 5);
40 pr_info!("{} message (level {}) with args\n", "Info", 6);
42 pr_info!("A {} that", "line");
43 pr_cont!(" is {}", "continued");
44 pr_cont!(" with {}\n", "args");
50 impl Drop for RustPrint {
52 pr_info!("Rust printing macros sample (exit)\n");