mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
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:
parent
1b968e8aa3
commit
fda978c8cc
1 changed files with 9 additions and 1 deletions
10
src/log.cpp
10
src/log.cpp
|
@ -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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue