Skip to content
Snippets Groups Projects
Commit bc8c365b authored by Guillaume Pasero's avatar Guillaume Pasero
Browse files

ENH: filter watcher logs for non-interactive cout

parent eb690f1b
No related branches found
No related tags found
2 merge requests!621Release 7.0 (master),!364No progress to file
......@@ -93,6 +93,10 @@ private:
int m_StarsCount;
int m_CurrentNbStars;
bool m_CoutIsConsole;
std::string m_Buffer;
};
} // end namespace otb
......
......@@ -24,6 +24,7 @@
#include "otbStandardOneLineFilterWatcher.h"
#include "otbStopwatch.h"
#include "otbSystem.h"
namespace otb
{
......@@ -31,7 +32,8 @@ namespace otb
StandardOneLineFilterWatcher
::StandardOneLineFilterWatcher()
: m_StarsCount(50),
m_CurrentNbStars(-1)
m_CurrentNbStars(-1),
m_CoutIsConsole( System::IsInteractive(1) )
{
}
......@@ -40,7 +42,8 @@ StandardOneLineFilterWatcher
const char *comment)
: FilterWatcherBase(process, comment),
m_StarsCount(50),
m_CurrentNbStars(-1)
m_CurrentNbStars(-1),
m_CoutIsConsole( System::IsInteractive(1) )
{
}
......@@ -49,7 +52,8 @@ StandardOneLineFilterWatcher
const std::string& comment)
: FilterWatcherBase(process, comment.c_str()),
m_StarsCount(50),
m_CurrentNbStars(-1)
m_CurrentNbStars(-1),
m_CoutIsConsole( System::IsInteractive(1) )
{
}
......@@ -82,12 +86,22 @@ StandardOneLineFilterWatcher
{
std::string stars(nbStars, '*');
std::string blanks(nbBlanks, ' ');
std::cout << "\r"
<< m_Comment
<< ": "
<< progressPercent << "% [" << stars << blanks << "]"
<< std::flush;
if (m_CoutIsConsole)
{
std::cout << "\r"
<< m_Comment
<< ": "
<< progressPercent << "% [" << stars << blanks << "]"
<< std::flush;
}
else
{
std::ostringstream oss;
oss << m_Comment
<< ": "
<< progressPercent << "% [" << stars << blanks << "]";
m_Buffer = oss.str();
}
}
m_CurrentNbStars = nbStars;
......@@ -107,6 +121,12 @@ StandardOneLineFilterWatcher
{
m_Stopwatch.Stop();
if (m_Process && !m_CoutIsConsole)
{
std::cout << m_Buffer;
m_Buffer = std::string("");
}
std::cout << " (";
m_Stopwatch.GetElapsedHumanReadableTime(std::cout);
std::cout << ")"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment