Skip to content

Commit

Permalink
Merge pull request #93 from paulsengroup/fix/windows-logging
Browse files Browse the repository at this point in the history
Re-enable logging on Windows
  • Loading branch information
robomics authored Oct 18, 2024
2 parents 50cd57b + e73871e commit 8c3eb4f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ if(WIN32)
INTERFACE
NOMINMAX
_CRT_SECURE_NO_WARNINGS
_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR # https://github.com/gabime/spdlog/issues/3212
)
endif()

Expand Down
11 changes: 1 addition & 10 deletions src/cooler_file_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,11 @@ void CoolerFileWriter::finalize([[maybe_unused]] std::string_view log_lvl_str,

assert(_w.has_value());
// NOLINTBEGIN(*-unchecked-optional-access)
#ifndef _WIN32
// TODO fixme
// There is something very odd going on when trying to call most spdlog functions from within
// Python bindings on recent versions of Windows.
// Possibly related to https://github.com/gabime/spdlog/issues/3212
const auto log_lvl = spdlog::level::from_str(normalize_log_lvl(log_lvl_str));
const auto previous_lvl = spdlog::default_logger()->level();
spdlog::default_logger()->set_level(log_lvl);

SPDLOG_INFO(FMT_STRING("finalizing file \"{}\"..."), _path);
#endif
try {
std::visit(
[&](const auto &num) {
Expand All @@ -131,17 +125,14 @@ void CoolerFileWriter::finalize([[maybe_unused]] std::string_view log_lvl_str,
},
_w->open("0").pixel_variant());
} catch (...) {
#ifndef _WIN32
spdlog::default_logger()->set_level(previous_lvl);
#endif
throw;
}

_finalized = true;
SPDLOG_INFO(FMT_STRING("merged {} cooler(s) into file \"{}\""), _w->cells().size(), _path);
#ifndef _WIN32
spdlog::default_logger()->set_level(previous_lvl);
#endif

const std::string sclr_path{_w->path()};
_w.reset();
std::filesystem::remove(sclr_path); // NOLINT
Expand Down
10 changes: 0 additions & 10 deletions src/hic_file_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,20 @@ void HiCFileWriter::finalize([[maybe_unused]] std::string_view log_lvl_str) {
fmt::format(FMT_STRING("finalize() was already called on file \"{}\""), _w.path()));
}

#ifndef _WIN32
// TODO fixme
// There is something very odd going on when trying to call most spdlog functions from within
// Python bindings on recent versions of Windows.
// Possibly related to https://github.com/gabime/spdlog/issues/3212
const auto log_lvl = spdlog::level::from_str(normalize_log_lvl(log_lvl_str));
const auto previous_lvl = spdlog::default_logger()->level();
spdlog::default_logger()->set_level(log_lvl);

SPDLOG_INFO(FMT_STRING("finalizing file \"{}\"..."), _w.path());
#endif
try {
_w.serialize();
_finalized = true;
} catch (...) {
#ifndef _WIN32
spdlog::default_logger()->set_level(previous_lvl);
#endif
throw;
}
SPDLOG_INFO(FMT_STRING("successfully finalized \"{}\"!"), _w.path());
#ifndef _WIN32
spdlog::default_logger()->set_level(previous_lvl);
#endif
}

std::filesystem::path HiCFileWriter::path() const noexcept {
Expand Down

0 comments on commit 8c3eb4f

Please sign in to comment.