Skip to content

Commit

Permalink
update log handler (#1793)
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir authored Dec 14, 2023
1 parent 0a44ba7 commit ae4c29f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/solver/utils/ortools_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ void OrtoolsLogHandler::init()
{
#ifdef __linux__
if (log_file_per_thread_.empty()
|| (file_pointer = fopen(log_file_per_thread_.string().c_str(), "a+")) == nullptr)
|| (file_pointer_ = fopen(log_file_per_thread_.string().c_str(), "a+")) == nullptr)
#elif _WIN32
if (log_file_per_thread_.empty()
|| (file_pointer = _fsopen(log_file_per_thread_.string().c_str(), "a+", _SH_DENYNO))
|| (file_pointer_ = _fsopen(log_file_per_thread_.string().c_str(), "a+", _SH_DENYNO))
== nullptr)
#endif
{
Expand All @@ -76,7 +76,7 @@ void OrtoolsLogHandler::init()
}
else
{
setvbuf(file_pointer, nullptr, _IONBF, 0);
setvbuf(file_pointer_, nullptr, _IONBF, 0);
}
}
else
Expand All @@ -87,10 +87,10 @@ void OrtoolsLogHandler::init()

OrtoolsLogHandler::~OrtoolsLogHandler()
{
if (file_pointer)
if (file_pointer_)
{
fclose(file_pointer);
file_pointer = nullptr;
fclose(file_pointer_);
file_pointer_ = nullptr;
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/solver/utils/ortools_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class OrtoolsLogHandler : public LogHandlerInterface

FILE* where_to_write()
{
return file_pointer;
return file_pointer_;
}

void copy_log(Solver::IResultWriter& writer) const;
Expand All @@ -90,11 +90,12 @@ class OrtoolsLogHandler : public LogHandlerInterface
void init();

std::ofstream log_writer_;
FILE* file_pointer = nullptr;
FILE* file_pointer_ = nullptr;
std::string solver_name_;
std::filesystem::path log_directory_ = ".";
std::filesystem::path log_file_per_thread_ = "";
};

class Nomenclature
{
public:
Expand Down

0 comments on commit ae4c29f

Please sign in to comment.