phoenix_lang/
log.rs

1#[macro_export]
2macro_rules! info {
3    ($($arg:tt)*) => {{
4        use colored::Colorize;
5        println!("{} {}", "[INFO]".green(), format!($($arg)*));
6    }};
7}
8
9#[macro_export]
10macro_rules! warn {
11    ($($arg:tt)*) => {{
12        use colored::Colorize;
13        println!("{} {}", "[WARNING]".yellow(), format!($($arg)*));
14    }};
15}
16
17#[macro_export]
18macro_rules! error {
19    ($($arg:tt)*) => {{
20        use colored::Colorize;
21        // reference to: https://xkcd.com/2200/
22        eprintln!("{} {}", "[ERROR]".red(), format!($($arg)*));
23    }};
24}
25
26#[macro_export]
27macro_rules! debug {
28    ($($arg:tt)*) => {
29        use colored::Colorize;
30        print!("{} ", "[DEBUG]".blue());
31        dbg!(format!($($arg)*));
32    };
33}
34
35#[macro_export]
36macro_rules! phoenix_error {
37    ($($arg:tt)*) => {{
38        use colored::Colorize;
39        use std::process::exit;
40        // reference to: https://xkcd.com/2200/
41        eprintln!("[{}:{}] {} {}\nPlease Report this as a bug here: https://github.com/TomtheCoder2/phoenix\n\n{}", file!(), line!(), "[PHOENIX ERROR]".red(), format!($($arg)*), "\
42        If you're seeing this, the code is in what I thought was an unreachable state. \
43        I could give you advice for what to do. \
44        But honestly, why should you trust me? \
45        I clearly screwed this up. I'm writing a message that should never appear, yet \
46        I know it will probably appear someday. \
47        On a deep level, I know I'm not up to this task. I'm so sorry.");
48        exit(1);
49    }};
50}