Skip to content

Commit

Permalink
add check on file
Browse files Browse the repository at this point in the history
  • Loading branch information
a-zakir committed Oct 11, 2023
1 parent c78454d commit a6f6855
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/cpp/benders/logger/UserFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ UserFile::UserFile(const std::filesystem::path &filename) {
}
}

UserFile::~UserFile() { _file.close(); }
UserFile::~UserFile() {
if (_file.is_open()) {
_file.close();
}
}

void UserFile::display_message(const std::string &str) {
_file << PrefixMessage(LogUtils::LOGLEVEL::INFO, CONTEXT) << str << std::endl;
Expand Down

0 comments on commit a6f6855

Please sign in to comment.