Skip to content

Commit

Permalink
Revert usage of smart pointer for _log_stream
Browse files Browse the repository at this point in the history
  • Loading branch information
HomesGH authored Sep 11, 2024
1 parent 0808152 commit 5c5c4ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/utils/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ Logger::Logger(logLevel level, std::string prefix) :
filenamestream << ".log";
_filename = filenamestream.str();

_log_stream = std::make_shared<std::ofstream>(_filename.c_str());
_log_stream = new std::ofstream(_filename.c_str());
*_log_stream << std::boolalpha; // Print boolean as true/false
}

Logger::~Logger() {
*_log_stream << std::flush;
if (_filename != "")
(static_cast<std::ofstream*> (_log_stream))->close();
}

/// allow logging only for a single process
void Logger::set_mpi_output_root(int root) {
Expand Down
4 changes: 2 additions & 2 deletions src/utils/Logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class Logger {
logLevel _msg_log_level;
bool _do_output;
std::string _filename;
std::shared_ptr<std::ostream> _log_stream;
std::ostream *_log_stream;
std::map<logLevel, std::string> logLevelNames;
#ifdef USE_GETTIMEOFDAY
timeval _starttime;
Expand Down Expand Up @@ -129,7 +129,7 @@ class Logger {

Logger(logLevel level, std::string prefix); // Write to file

~Logger() = default;
~Logger();

/// General output template for variables, strings, etc.
template<typename T>
Expand Down

0 comments on commit 5c5c4ff

Please sign in to comment.