Skip to content

Commit

Permalink
Merge pull request #398 from JeffersonLab/nbrei_logger_mutex
Browse files Browse the repository at this point in the history
Put logger mutex behind a preprocessor flag
  • Loading branch information
nathanwbrei authored Jan 3, 2025
2 parents e583654 + 760610e commit 37e9200
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/libraries/JANA/JLogger.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
#include <time.h>
#include <mutex>

#ifndef JANA2_USE_LOGGER_MUTEX
#define JANA2_USE_LOGGER_MUTEX 0
#endif


struct JLogger {
enum class Level { TRACE, DEBUG, INFO, WARN, ERROR, FATAL, OFF };
Expand Down Expand Up @@ -107,9 +111,10 @@ class JLogMessage : public std::stringstream {
}

virtual ~JLogMessage() {
#if JANA2_USE_LOGGER_MUTEX
static std::mutex cout_mutex;
std::lock_guard<std::mutex> lock(cout_mutex);

#endif
std::string line;
std::ostringstream oss;
while (std::getline(*this, line)) {
Expand Down

0 comments on commit 37e9200

Please sign in to comment.