This commit is contained in:
Your Name 2025-05-18 12:40:26 +12:00
parent e7c6d38273
commit 668cef5a05
2 changed files with 54 additions and 0 deletions

View File

@ -129,6 +129,9 @@ int help_handler(const CommandContext& ctx) {
std::cout << std::endl;
show_command("start");
show_command("stop");
std::cout << std::endl;
show_command("ssh");
std::cout << std::endl;
}
return 0;
}

View File

@ -0,0 +1,51 @@
#ifndef OUTPUT_HPP
#define OUTPUT_HPP
#include <iostream>
#include <string>
#include <vector>
/*
output.hpp and output.cpp - simple output helpers.
Defines ostreams:
debug, info, warning, error.
These ostreams can be used with C++23 print and println, e.g.
std::println(debug, "funny variable: {}={}","my_var",my_var);
Also defines a few helper functions:
PrintDebug(const std::string& msg); // equivalent to std::println(debug, msg);
PrintInfo(const std::string& msg); // equivalent to std::println(info, msg);
PrintWarning(const std::string& msg); // equivalent to std::println(warning, msg);
PrintError(const std::string& msg); // equivalent to std::println(error, msg);
Output for these streams for each line is formatted as:
[DBG] <message>
[INF] <message>
[WRN] <message>
[ERR] <message>
The output is coloured, and the tag is printed in grey.
In addition, when not using any of the above, helper routines for coloring the output of cout and cerr are provided.
SetColour(std::ostream& os, sColour colour);
Where sColour is an enum:
enum class sColour {
RESET,
DEBUG,
INFO,
WARNING,
ERROR
};
*/
#endif // OUTPUT_HPP