From a6f6855614a480184527089972ce9c487f6b39a4 Mon Sep 17 00:00:00 2001 From: Abdoulbari ZAKIR Date: Wed, 11 Oct 2023 16:56:42 +0200 Subject: [PATCH] add check on file --- src/cpp/benders/logger/UserFile.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cpp/benders/logger/UserFile.cpp b/src/cpp/benders/logger/UserFile.cpp index 2668fdb18..b856f72d7 100644 --- a/src/cpp/benders/logger/UserFile.cpp +++ b/src/cpp/benders/logger/UserFile.cpp @@ -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;