1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*********************************************************************************************************************** 
 * Copyright (c) 2019 by the authors
 * 
 * Author: André Borrmann 
 * License: Appache License 2.0
 **********************************************************************************************************************/

//! # Convinient output macros to print formatted strings to the configured channel of the console
//! 
//! Provide the print!() and println!() macro's as used in the libstd crate which is not available here
//! as we do need formatting on the parameter and formatting requires memory allocation the
//! use of this functions is only possible if a global allocator is implemented.<br>
//! You may use the ``ruspiro-allocator`` crate.

/// This macro works like the ``std::print!`` one.
#[macro_export]
macro_rules! print {
    //$crate::macros::alloc::
    ($($arg:tt)*) => ($crate::print($crate::alloc::format!($($arg)*).as_str()));
}

/// This macro works like the ``std::println!`` one
#[macro_export]
macro_rules! println {
    () => ($crate::print!("\r\n"));
    ($($arg:tt)*) => ({
        $crate::print!("{}\r\n", $crate::alloc::format!($($arg)*));
    })
}

/// This macro prefixes the output with "I: <module-path> -". Other than this it works like the ``std::println!``
#[macro_export]
macro_rules! info {
    ($($arg:tt)*) => ({
        $crate::print!("I: {} - {}\r\n", module_path!(), $crate::alloc::format!($($arg)*));
    })
}

/// This macro prefixes the output with "W: <module-path> -". Other than this it works like the ``std::println!``
#[macro_export]
macro_rules! warn {
    ($($arg:tt)*) => ({
        $crate::print!("W: {} - {}\r\n", module_path!(), $crate::alloc::format!($($arg)*));
    })
}

/// This macro prefixes the output with "E: <module-path> -". Other than this it works like the ``std::println!``
#[macro_export]
macro_rules! error {
    ($($arg:tt)*) => ({
        $crate::print!("E: {} - {}\r\n", module_path!(), $crate::alloc::format!($($arg)*));
    })
}