Skip to content

Commit

Permalink
chore(filesystem_extractor): add more debug/trace logging
Browse files Browse the repository at this point in the history
  • Loading branch information
mhx committed Aug 25, 2024
1 parent 9f366b2 commit d89ad6b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/utility/filesystem_extractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ class filesystem_extractor_ final : public filesystem_extractor::impl {

void open_archive(std::filesystem::path const& output,
std::string const& format) override {
LOG_DEBUG << "opening archive file in " << format << " format";

a_ = ::archive_write_new();

check_result(::archive_write_set_format_by_name(a_, format.c_str()));
Expand Down Expand Up @@ -140,6 +142,8 @@ class filesystem_extractor_ final : public filesystem_extractor::impl {
iot_ = std::make_unique<std::thread>(
[this, &os, fd = pipefd_[0]] { pump(os, fd); });

LOG_DEBUG << "opening archive stream in " << format << " format";

a_ = ::archive_write_new();

check_result(::archive_write_set_format_by_name(a_, format.c_str()));
Expand All @@ -162,17 +166,22 @@ class filesystem_extractor_ final : public filesystem_extractor::impl {

void close() override {
if (a_) {
LOG_DEBUG << "closing archive";
check_result(::archive_write_close(a_));
LOG_TRACE << "freeing archive";
::archive_write_free(a_);
a_ = nullptr;
}

if (iot_) {
LOG_TRACE << "closing pipe[1]";
closefd(pipefd_[1]);

LOG_TRACE << "joining I/O thread";
iot_->join();
iot_.reset();

LOG_TRACE << "closing pipe[0]";
closefd(pipefd_[0]);
}
}
Expand Down Expand Up @@ -200,6 +209,8 @@ class filesystem_extractor_ final : public filesystem_extractor::impl {
// Flawfinder: ignore
auto rv = ::read(fd, buf.data(), buf.size());

LOG_TRACE << "read() returned " << rv;

if (rv <= 0) {
if (rv < 0) {
LOG_ERROR << "read(): " << ::strerror(errno);
Expand Down

0 comments on commit d89ad6b

Please sign in to comment.