.
This commit is contained in:
parent
e7c6d38273
commit
668cef5a05
@ -129,6 +129,9 @@ int help_handler(const CommandContext& ctx) {
|
|||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
show_command("start");
|
show_command("start");
|
||||||
show_command("stop");
|
show_command("stop");
|
||||||
|
std::cout << std::endl;
|
||||||
|
show_command("ssh");
|
||||||
|
std::cout << std::endl;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
51
source/src/utils/output.hpp
Normal file
51
source/src/utils/output.hpp
Normal 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
|
Loading…
x
Reference in New Issue
Block a user