diff options
Diffstat (limited to 'src/log.cpp')
-rw-r--r-- | src/log.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/log.cpp b/src/log.cpp index 07c12516..3222c856 100644 --- a/src/log.cpp +++ b/src/log.cpp @@ -29,22 +29,22 @@ #include <sstream> -Logger::Logger(const std::string &logFilename) +Logger::~Logger() { - logFile.open(logFilename.c_str(), std::ios_base::trunc); - - if (!logFile.is_open()) + if (logFile.is_open()) { - std::cout << "Warning: error while opening " << logFilename << - " for writing.\n"; + logFile.close(); } } -Logger::~Logger() +void Logger::setLogFile(const std::string &logFilename) { - if (logFile.is_open()) + logFile.open(logFilename.c_str(), std::ios_base::trunc); + + if (!logFile.is_open()) { - logFile.close(); + std::cout << "Warning: error while opening " << logFilename << + " for writing.\n"; } } |