From fda978c8cc8de970651716f64ca0127e0bb4f148 Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Tue, 3 Mar 2020 20:32:39 -0600 Subject: [PATCH] Support multiline debug log messages With this change, if there are debug messages that are multiple lines, each line will be prefaced with the '>>' marker. Signed-off-by: Shaun Ruffell --- src/log.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/log.cpp b/src/log.cpp index 4bb68d77..c1cb4aa4 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -27,6 +27,7 @@ #include #include #include +#include static bool debugMode = false; static std::string debugIndicator = ">>"; @@ -54,7 +55,14 @@ void setDebugColor (const Color& color) void debug (const std::string& msg) { if (debugMode) - std::cout << debugColor.colorize (debugIndicator + " " + msg) << "\n"; + { + std::stringstream sstr (msg); + std::string line; + while (std::getline (sstr, line, '\n')) + { + std::cout << debugColor.colorize (debugIndicator + " " + line) << "\n"; + } + } } ////////////////////////////////////////////////////////////////////////////////