summaryrefslogtreecommitdiff
path: root/util/output.hh
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-06 18:30:19 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-06 18:30:19 -0500
commita8f34e5d4bf1dcd56a10790b12d23b8a7ab32b2e (patch)
treec3090ee81331830a83ec765558ad2882500ffed7 /util/output.hh
parent5c82a446b9110cf27958ad9c82535b84d0565e10 (diff)
downloadhorizon-a8f34e5d4bf1dcd56a10790b12d23b8a7ab32b2e.tar.gz
horizon-a8f34e5d4bf1dcd56a10790b12d23b8a7ab32b2e.tar.bz2
horizon-a8f34e5d4bf1dcd56a10790b12d23b8a7ab32b2e.tar.xz
horizon-a8f34e5d4bf1dcd56a10790b12d23b8a7ab32b2e.zip
util: Add more output types
Diffstat (limited to 'util/output.hh')
-rw-r--r--util/output.hh52
1 files changed, 44 insertions, 8 deletions
diff --git a/util/output.hh b/util/output.hh
index 9281301..ac356bc 100644
--- a/util/output.hh
+++ b/util/output.hh
@@ -16,17 +16,20 @@
#include <string>
#include <iostream>
-/*! Prints an error message to the cerr stream.
- * @param where The location where the error occurred.
- * @param message The error that occurred.
- * @param detail Additional detail for the error, if available.
+/*! Outputs a message of the specified +type+ to the log stream.
+ * @param type The type of message to output.
+ * @param colour The colourisation of the message.
+ * @param where The location that triggered the message.
+ * @param message The message.
+ * @param detail Additional detail for the message, if available.
* @param pretty Whether or not to colourise (interactive output).
*/
-inline void output_error(std::string where, std::string message,
- std::string detail = "", bool pretty = false) {
+inline void output_message(std::string type, std::string colour,
+ std::string where, std::string message,
+ std::string detail = "", bool pretty = false) {
std::cerr << where << ": ";
- if(pretty) std::cerr << "\033[31;1m";
- std::cerr << "error: ";
+ if(pretty) std::cerr << "\033[" + colour + ";1m";
+ std::cerr << type << ": ";
if(pretty) std::cerr << "\033[0;1m";
std::cerr << message;
if(pretty) std::cerr << "\033[0m";
@@ -36,4 +39,37 @@ inline void output_error(std::string where, std::string message,
std::cerr << std::endl;
}
+/*! Outputs an error message.
+ * @param where The location where the error occurred.
+ * @param message The error that occurred.
+ * @param detail Additional detail for the error, if available.
+ * @param pretty Whether or not to colourise (interactive output).
+ */
+inline void output_error(std::string where, std::string message,
+ std::string detail = "", bool pretty = false) {
+ output_message("error", "31", where, message, detail, pretty);
+}
+
+/*! Outputs a warning message.
+ * @param where The location where the warning occurred.
+ * @param message The warning to display.
+ * @param detail Additional detail for the warning, if available.
+ * @param pretty Whether or not to colourise (interactive output).
+ */
+inline void output_warning(std::string where, std::string message,
+ std::string detail = "", bool pretty = false) {
+ output_message("warning", "33", where, message, detail, pretty);
+}
+
+/*! Outputs an informational message.
+ * @param where The location relevant to the information.
+ * @param message The information to display.
+ * @param detail Additional detail for the information, if available.
+ * @param pretty Whether or not to colourise (interactive output).
+ */
+inline void output_info(std::string where, std::string message,
+ std::string detail = "", bool pretty = false) {
+ output_message("info", "36", where, message, detail, pretty);
+}
+
#endif /* !__HORIZON_OUTPUT_HH_ */