3131
3232constexpr const char NOCOLOR[] = " \033 [0m" ;
3333constexpr const char NOCOLOR_BOLD[] = " \033 [0m\033 [1m" ;
34+
35+ // Didn't find what you were looking for.
3436constexpr const char UNKNOWN[] = " (unknown)" ;
3537
36- // Usually in neofetch/fastfetch when some infos couldn't be queried,
37- // they remove it from the display. With customfetch is kinda difficult to know when to remove
38- // the info to display, since it's all modular with tags, so I have created
39- // magic line to be sure that I don't cut the wrong line.
38+ // Usually in neofetch/fastfetch when some infos couldn't be queried, they remove it from the display.
39+ // With customfetch is kinda difficult to know when to remove the info to display,
40+ // since it's all modular with tags, so I have created a "magic line" to be sure that I don't cut the wrong line.
4041//
41- // Every instance of this string in a layout line, the whole line will be erased.
42+ // Every instance of this string found in a layout line, the whole line will be erased.
4243constexpr const char MAGIC_LINE[] = " (cut this line NOW!! RAHHH)" ;
4344
4445#define APICALL extern " C"
@@ -52,39 +53,50 @@ inline bool debug_print = true;
5253inline bool debug_print = false ;
5354#endif
5455
56+ // std::format function arguments
57+ // Print to stderr an error with header 'ERROR:' in red
5558template <typename ... Args>
5659void error (const std::string_view fmt, Args&&... args) noexcept
5760{
5861 fmt::print (stderr, " \033 [1;31mERROR: {}\033 [0m\n " ,
5962 fmt::format (fmt::runtime (fmt), std::forward<Args>(args)...));
6063}
6164
65+ // std::format function arguments
66+ // Print to stderr an error with header 'FATAL:' in red and exit with failure code
6267template <typename ... Args>
6368void die (const std::string_view fmt, Args&&... args) noexcept
6469{
6570 fmt::print (stderr, " \033 [1;31mFATAL: {}\033 [0m\n " ,
6671 fmt::format (fmt::runtime (fmt), std::forward<Args>(args)...));
67- std::exit (1 );
72+ std::exit (EXIT_FAILURE );
6873}
6974
75+ // std::format function arguments
76+ // Print to stdout a debug msg with header '[DEBUG]' in hot-pink color
77+ // only if debug_print is set (do not modify it).
7078template <typename ... Args>
7179void debug (const std::string_view fmt, Args&&... args) noexcept
7280{
7381 if (debug_print)
74- fmt::print (" \033 [1;38;2;255;105;180m[DEBUG]:\033 [0m {}\n " ,
82+ fmt::print (stdout, " \033 [1;38;2;255;105;180m[DEBUG]:\033 [0m {}\n " ,
7583 fmt::format (fmt::runtime (fmt), std::forward<Args>(args)...));
7684}
7785
86+ // std::format function arguments
87+ // Print to stderr a warning with header 'WARNING:' in yellow
7888template <typename ... Args>
7989void warn (const std::string_view fmt, Args&&... args) noexcept
8090{
81- fmt::print (" \033 [1;33mWARNING: {}\033 [0m\n " ,
91+ fmt::print (stderr, " \033 [1;33mWARNING: {}\033 [0m\n " ,
8292 fmt::format (fmt::runtime (fmt), std::forward<Args>(args)...));
8393}
8494
95+ // std::format function arguments
96+ // Print to stdout an info msg with header 'INFO:' in cyan
8597template <typename ... Args>
8698void info (const std::string_view fmt, Args&&... args) noexcept
8799{
88- fmt::print (" \033 [1;36mINFO: {}\033 [0m\n " ,
100+ fmt::print (stdout, " \033 [1;36mINFO: {}\033 [0m\n " ,
89101 fmt::format (fmt::runtime (fmt), std::forward<Args>(args)...));
90102}
0 commit comments