summaryrefslogtreecommitdiff
path: root/util/output.hh
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-08 22:57:44 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2019-10-08 22:57:44 -0500
commitee19bcceefbd1c4c604d1afe832e0b6f669d5eae (patch)
tree896cfe715aea1e9786896e74d02b5bffab21ba69 /util/output.hh
parent831f22fb241e6bbf6e03a61f76932a22a63e4564 (diff)
downloadhorizon-ee19bcceefbd1c4c604d1afe832e0b6f669d5eae.tar.gz
horizon-ee19bcceefbd1c4c604d1afe832e0b6f669d5eae.tar.bz2
horizon-ee19bcceefbd1c4c604d1afe832e0b6f669d5eae.tar.xz
horizon-ee19bcceefbd1c4c604d1afe832e0b6f669d5eae.zip
Make +pretty+ a global var instead of passed everywhere
Diffstat (limited to 'util/output.hh')
-rw-r--r--util/output.hh42
1 files changed, 18 insertions, 24 deletions
diff --git a/util/output.hh b/util/output.hh
index fa81127..cbb1d05 100644
--- a/util/output.hh
+++ b/util/output.hh
@@ -13,32 +13,30 @@
#ifndef __HORIZON_OUTPUT_HH_
#define __HORIZON_OUTPUT_HH_
+extern bool pretty;
+
#include <string>
#include <iostream>
-/*! Bolds output on +stream+ if it's a TTY.
- * @param pretty Whether to act.
+/*! Bolds output on +stream+ if pretty output is desired.
* @param stream The stream to turn bold.
*/
-inline void bold_if_pretty(bool pretty, std::ostream &stream) {
+inline void bold_if_pretty(std::ostream &stream) {
if(pretty) stream << "\033[0;1m";
}
-/*! ANSI colour code on +stream+ if +pretty+.
- * @param pretty Whether to act.
+/*! ANSI colour code on +stream+ if pretty output is desired.
* @param stream The stream on which to colourise output.
* @param what The colour code.
*/
-inline void colour_if_pretty(bool pretty, std::ostream &stream,
- std::string what) {
+inline void colour_if_pretty(std::ostream &stream, std::string what) {
if(pretty) stream << "\033[" + what + ";1m";
}
-/*! Reset all formatting on +stream+ if +pretty+.
- * @param pretty Whether to act.
+/*! Reset all formatting on +stream+ if pretty output is desired.
* @param stream The stream on which to reset formatting.
*/
-inline void reset_if_pretty(bool pretty, std::ostream &stream) {
+inline void reset_if_pretty(std::ostream &stream) {
if(pretty) stream << "\033[0m";
}
@@ -48,17 +46,16 @@ inline void reset_if_pretty(bool pretty, std::ostream &stream) {
* @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_message(std::string type, std::string colour,
std::string where, std::string message,
- std::string detail = "", bool pretty = false) {
+ std::string detail = "") {
std::cerr << where << ": ";
- colour_if_pretty(pretty, std::cerr, colour);
+ colour_if_pretty(std::cerr, colour);
std::cerr << type << ": ";
- bold_if_pretty(pretty, std::cerr);
+ bold_if_pretty(std::cerr);
std::cerr << message;
- reset_if_pretty(pretty, std::cerr);
+ reset_if_pretty(std::cerr);
if(!detail.empty()) {
std::cerr << ": " << detail;
}
@@ -69,33 +66,30 @@ inline void output_message(std::string type, std::string colour,
* @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);
+ std::string detail = "") {
+ output_message("error", "31", where, message, detail);
}
/*! 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);
+ std::string detail = "") {
+ output_message("warning", "33", where, message, detail);
}
/*! 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);
+ std::string detail = "") {
+ output_message("info", "36", where, message, detail);
}
#endif /* !__HORIZON_OUTPUT_HH_ */