Skip to content

Commit

Permalink
Merge pull request log4cplus#632 from wilx/master
Browse files Browse the repository at this point in the history
Merge.
  • Loading branch information
wilx authored Sep 17, 2024
2 parents ed6e0f9 + 3b218ea commit 57292fb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
7 changes: 4 additions & 3 deletions include/log4cplus/helpers/eventcounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#pragma once
#endif

#include <log4cplus/internal/threadsafetyanalysis.h>
#include <log4cplus/thread/syncprims.h>
#include <cstddef>
#include <atomic>
Expand Down Expand Up @@ -78,9 +79,9 @@ class LOG4CPLUS_EXPORT SteadyClockGate

private:
log4cplus::thread::SimpleMutex mtx;
Duration const pause_duration;
TimePoint timeout_point;
TimePoint prev_timeout_point;
Duration const pause_duration LOG4CPLUS_TSA_GUARDED_BY (mtx);
TimePoint timeout_point LOG4CPLUS_TSA_GUARDED_BY (mtx);
TimePoint prev_timeout_point LOG4CPLUS_TSA_GUARDED_BY (mtx);
};


Expand Down
28 changes: 25 additions & 3 deletions include/log4cplus/loggingmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,8 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &,
//! Helper macro for LOG4CPLUS_ASSERT() macro.
#define LOG4CPLUS_ASSERT_STRINGIFY(X) #X

//! If the condition given in second parameter evaluates false, this
//! macro logs it using FATAL log level, including the condition's
//! source text.
//! If the `condition` evaluates false, this macro logs it using FATAL
//! log level, including the `condition`'s source text.
#define LOG4CPLUS_ASSERT(logger, condition) \
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
do { \
Expand All @@ -544,5 +543,28 @@ LOG4CPLUS_EXPORT void macro_forced_log (log4cplus::Logger const &,
} while (false) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()

//! If the `condition` evaluates false, this macro logs a message
//! formatted from `printf` format string passed in 3rd and remaining
//! arguments.
#define LOG4CPLUS_ASSERT_FMT(logger, condition, ...) \
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
do { \
if (! (condition)) [[unlikely]] { \
LOG4CPLUS_FATAL_FMT ((logger), __VA_ARGS__); \
} \
} while (false) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()

//! If the `condition` evaluates false, this macro logs a message
//! formatted from `std::format` format string passed in 3rd and remaining
//! arguments.
#define LOG4CPLUS_ASSERT_FORMAT(logger, condition, ...) \
LOG4CPLUS_SUPPRESS_DOWHILE_WARNING() \
do { \
if (! (condition)) [[unlikely]] { \
LOG4CPLUS_FATAL_FORMAT ((logger), __VA_ARGS__); \
} \
} while (false) \
LOG4CPLUS_RESTORE_DOWHILE_WARNING()

#endif /* LOG4CPLUS_LOGGING_MACROS_HEADER_ */

0 comments on commit 57292fb

Please sign in to comment.