Enhancement

- Output error, header, footnote and debug messages on standard error.
This commit is contained in:
Louis-Claude Canon
2012-06-15 21:16:06 +02:00
committed by Paul Beckingham
parent b093d23f1f
commit b45a305df2
28 changed files with 101 additions and 82 deletions

View File

@@ -208,9 +208,9 @@ int Context::initialize (int argc, const char** argv)
std::vector <std::string>::iterator d;
for (d = debugMessages.begin (); d != debugMessages.end (); ++d)
if (color ())
std::cout << colorizeDebug (*d) << "\n";
std::cerr << colorizeDebug (*d) << "\n";
else
std::cout << *d << "\n";
std::cerr << *d << "\n";
}
// Dump all headers, controlled by 'header' verbosity token.
@@ -219,9 +219,9 @@ int Context::initialize (int argc, const char** argv)
std::vector <std::string>::iterator h;
for (h = headers.begin (); h != headers.end (); ++h)
if (color ())
std::cout << colorizeHeader (*h) << "\n";
std::cerr << colorizeHeader (*h) << "\n";
else
std::cout << *h << "\n";
std::cerr << *h << "\n";
}
// Dump all footnotes, controlled by 'footnote' verbosity token.
@@ -230,9 +230,9 @@ int Context::initialize (int argc, const char** argv)
std::vector <std::string>::iterator f;
for (f = footnotes.begin (); f != footnotes.end (); ++f)
if (color ())
std::cout << colorizeFootnote (*f) << "\n";
std::cerr << colorizeFootnote (*f) << "\n";
else
std::cout << *f << "\n";
std::cerr << *f << "\n";
}
// Dump all errors, non-maskable.
@@ -242,9 +242,9 @@ int Context::initialize (int argc, const char** argv)
std::vector <std::string>::iterator e;
for (e = errors.begin (); e != errors.end (); ++e)
if (color ())
std::cout << colorizeFootnote (*e) << "\n";
std::cerr << colorizeFootnote (*e) << "\n";
else
std::cout << *e << "\n";
std::cerr << *e << "\n";
}
timer_init.stop ();
@@ -311,9 +311,9 @@ int Context::run ()
std::vector <std::string>::iterator d;
for (d = debugMessages.begin (); d != debugMessages.end (); ++d)
if (color ())
std::cout << colorizeDebug (*d) << "\n";
std::cerr << colorizeDebug (*d) << "\n";
else
std::cout << *d << "\n";
std::cerr << *d << "\n";
}
// Dump all headers, controlled by 'header' verbosity token.
@@ -322,9 +322,9 @@ int Context::run ()
std::vector <std::string>::iterator h;
for (h = headers.begin (); h != headers.end (); ++h)
if (color ())
std::cout << colorizeHeader (*h) << "\n";
std::cerr << colorizeHeader (*h) << "\n";
else
std::cout << *h << "\n";
std::cerr << *h << "\n";
}
// Dump the report output.
@@ -336,9 +336,9 @@ int Context::run ()
std::vector <std::string>::iterator f;
for (f = footnotes.begin (); f != footnotes.end (); ++f)
if (color ())
std::cout << colorizeFootnote (*f) << "\n";
std::cerr << colorizeFootnote (*f) << "\n";
else
std::cout << *f << "\n";
std::cerr << *f << "\n";
}
// Dump all errors, non-maskable.
@@ -346,9 +346,9 @@ int Context::run ()
std::vector <std::string>::iterator e;
for (e = errors.begin (); e != errors.end (); ++e)
if (color ())
std::cout << colorizeFootnote (*e) << "\n";
std::cerr << colorizeFootnote (*e) << "\n";
else
std::cout << *e << "\n";
std::cerr << *e << "\n";
hooks.trigger ("on-exit");
return rc;

View File

@@ -51,9 +51,9 @@ extern Context context;
#define DEBUG_OUTPUT 0
#if DEBUG_OUTPUT > 0
#define DEBUG_STR(str) std::cout << "DEBUG: " << str << "\n"; std::cout.flush()
#define DEBUG_STR_PART(str) std::cout << "DEBUG: " << str; std::cout.flush()
#define DEBUG_STR_END(str) std::cout << str << "\n"; std::cout.flush()
#define DEBUG_STR(str) std::cerr << "DEBUG: " << str << "\n"; std::cerr.flush()
#define DEBUG_STR_PART(str) std::cerr << "DEBUG: " << str; std::cerr.flush()
#define DEBUG_STR_END(str) std::cerr << str << "\n"; std::cerr.flush()
#else
#define DEBUG_STR(str)
#define DEBUG_STR_PART(str)

View File

@@ -147,7 +147,6 @@ int CmdCustom::execute (std::string& output)
if (maxlines)
maxlines -= (context.verbose ("blank") ? 1 : 0)
+ table_header
+ (context.verbose ("footnote") ? context.footnotes.size () : 0)
+ 1; // "X tasks shown ..."
// Render.
@@ -161,6 +160,7 @@ int CmdCustom::execute (std::string& output)
<< view.render (filtered, sequence)
<< optionalBlankLine ();
// Print the number of rendered tasks
if (context.verbose ("affected"))
{
out << (filtered.size () == 1

View File

@@ -691,7 +691,7 @@ ARE_THESE_REALLY_HARMFUL:
if (oops)
{
std::cout << STRING_ERROR_PREFIX << problem << "\n";
std::cerr << STRING_ERROR_PREFIX << problem << "\n";
// Preserve the edits.
before = after;

View File

@@ -89,7 +89,22 @@ int CmdMerge::execute (std::string& output)
else
file = uri._path;
context.tdb2.merge (file);
// XXX the following function could indicate whether a modification was
// performed without an exception (by returning a boolean, within a status
// object or with a specific function)
try
{
context.tdb2.merge (file);
}
catch (std::string& e) {
if (e == STRING_TDB2_UP_TO_DATE)
{
output += e + "\n";
return 0;
}
else
throw e;
}
output += std::string (STRING_CMD_MERGE_COMPLETE) + "\n";

View File

@@ -113,7 +113,7 @@ int CmdShell::execute (std::string&)
catch (std::string& error)
{
std::cout << error << "\n";
std::cerr << error << "\n";
}
catch (...)

View File

@@ -76,7 +76,7 @@ int main (int argc, const char** argv)
catch (std::string& error)
{
std::cout << error << "\n";
std::cerr << error << "\n";
status = -1;
}