Skip to content

Commit

Permalink
Merge pull request #1700 from ApexAI/iox-1345-disable-lazy-evaluation
Browse files Browse the repository at this point in the history
Iox 1345 disable lazy evaluation
  • Loading branch information
elBoberido authored Sep 29, 2022
2 parents 5870d17 + 58ae8fb commit c3351d7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
10 changes: 9 additions & 1 deletion iceoryx_hoofs/include/iceoryx_hoofs/internal/log/logstream.inl
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,22 @@ inline LogStream::LogStream(const char* file, const int line, const char* functi
{
}

inline LogStream::LogStream(
const char* file, const int line, const char* function, LogLevel logLevel, bool doFlush) noexcept
: m_logger(Logger::get())
, m_doFlush(doFlush)
{
m_logger.createLogMessageHeader(file, line, function, logLevel);
}

inline LogStream::~LogStream() noexcept
{
flush();
}

inline void LogStream::flush() noexcept
{
if (!m_isFlushed)
if (!m_isFlushed && m_doFlush)
{
m_logger.flush();
m_isFlushed = true;
Expand Down
4 changes: 2 additions & 2 deletions iceoryx_hoofs/include/iceoryx_hoofs/log/logging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ inline bool isLogLevelActive(LogLevel logLevel)
// NOLINTJUSTIFICATION cannot be realized with templates or constexpr functions due to the the source location intrinsic
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
#define IOX_LOG_INTERNAL(file, line, function, level) \
if (iox::log::internal::isLogLevelActive(level)) \
iox::log::LogStream(file, line, function, level).self()
/* if (iox::log::internal::isLogLevelActive(level)) @todo iox-#1345 temporary workaround */ \
iox::log::LogStream(file, line, function, level, iox::log::internal::isLogLevelActive(level)).self()

} // namespace internal

Expand Down
6 changes: 6 additions & 0 deletions iceoryx_hoofs/include/iceoryx_hoofs/log/logstream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class LogStream
/// @param[in] logLevel is the log level for the log message
LogStream(const char* file, const int line, const char* function, LogLevel logLevel) noexcept;

/// @todo iox-#1345 temporary workaround
LogStream(const char* file, const int line, const char* function, LogLevel logLevel, bool doFlush) noexcept;

virtual ~LogStream() noexcept;

LogStream(const LogStream&) = delete;
Expand Down Expand Up @@ -194,6 +197,9 @@ class LogStream
// NOLINTNEXTLINE(cppcoreguidelines-avoid-const-or-ref-data-members)
Logger& m_logger;
bool m_isFlushed{false};

/// @todo iox-#1345 temporary workaround
bool m_doFlush{true};
};

} // namespace log
Expand Down

0 comments on commit c3351d7

Please sign in to comment.