Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add progress debug support #109

Merged
merged 4 commits into from
Jan 24, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix initialization.
abellgithub committed Jan 21, 2022

Verified

This commit was signed with the committer’s verified signature. The key has expired.
abellgithub Andrew Bell
commit a843558d4ebe0ba51257355267a312e3d26d715d
9 changes: 3 additions & 6 deletions untwine/ProgressWriter.cpp
Original file line number Diff line number Diff line change
@@ -16,13 +16,10 @@ namespace untwine
ProgressWriter::ProgressWriter() : m_fd(-1), m_debug(false), m_percent(0.0), m_increment(.01)
{}

ProgressWriter::ProgressWriter(int fd, bool debug) :
m_fd(fd), m_debug(debug), m_percent(0.0), m_increment(.01)
{}

void ProgressWriter::setFd(int fd)
void ProgressWriter::init(int fd, bool debug)
{
m_fd = fd;
m_debug = debug;
}

void ProgressWriter::setIncrement(double increment)
@@ -63,7 +60,7 @@ void ProgressWriter::write(double percent, const std::string& message)
void ProgressWriter::writeMessage(uint32_t percent, const std::string& message)
{
if (m_debug)
std::cout << "Progress (" << percent << ") " << message << "\n";
std::cout << "Untwine progress (" << percent << "% done): " << message << "\n";
if (m_fd < 0)
return;

5 changes: 2 additions & 3 deletions untwine/ProgressWriter.hpp
Original file line number Diff line number Diff line change
@@ -13,10 +13,9 @@ class ProgressWriter
static const PointCount ChunkSize = 100'000;

ProgressWriter();
ProgressWriter(int fd, bool debug);

// Set the progress file descriptor.
void setFd(int fd);
// Set the progress config..
void init(int fd = -1, bool debug = false);

/// Set the increment to use on the next call to setIncrement.
void setIncrement(double increment);
2 changes: 1 addition & 1 deletion untwine/Untwine.cpp
Original file line number Diff line number Diff line change
@@ -145,7 +145,7 @@ int main(int argc, char *argv[])
{
if (!handleOptions(arglist, options))
return 0;
progress.setFd(options.progressFd);
progress.init(options.progressFd, options.progressDebug);
createDirs(options);

epf::Epf preflight(common);