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 <sruffell@sruffell.net>
This commit is contained in:
Shaun Ruffell 2020-03-03 20:32:39 -06:00 committed by lauft
parent 1b968e8aa3
commit fda978c8cc

View file

@ -27,6 +27,7 @@
#include <Color.h>
#include <timew.h>
#include <iostream>
#include <sstream>
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";
}
}
}
////////////////////////////////////////////////////////////////////////////////