CatapultServer
v0.5.0.1 (Elephant)
|
Go to the documentation of this file.
26 namespace catapult {
namespace utils {
32 using Clock = std::chrono::steady_clock;
53 auto now = Clock::now();
62 uint64_t
millis(
const Clock::time_point& now)
const {
63 auto elapsedDuration = now -
m_last;
64 return static_cast<uint64_t>(std::chrono::duration_cast<std::chrono::milliseconds>(elapsedDuration).count());
76 #define CATAPULT_LOG_THROTTLE(LEVEL, THROTTLE_MILLIS) \
77 static utils::ThrottleLogger BOOST_LOG_UNIQUE_IDENTIFIER_NAME_INTERNAL(throttle_logger, __LINE__)(THROTTLE_MILLIS); \
78 if (!BOOST_LOG_UNIQUE_IDENTIFIER_NAME_INTERNAL(throttle_logger, __LINE__).isThrottled()) \
79 CATAPULT_LOG(LEVEL) << "[" << BOOST_LOG_UNIQUE_IDENTIFIER_NAME_INTERNAL(throttle_logger, __LINE__).counter() << " log count] "
std::atomic< uint32_t > m_counter
Definition: ThrottleLogger.h:69
std::chrono::steady_clock Clock
Definition: ThrottleLogger.h:32
Clock::time_point m_last
Definition: ThrottleLogger.h:70
uint64_t m_throttleMillis
Definition: ThrottleLogger.h:68
utils::SpinLock m_lock
Definition: ThrottleLogger.h:71
Definition: SpinLock.h:31
Definition: ThrottleLogger.h:30
bool isThrottled()
Returns false if a log should be output.
Definition: ThrottleLogger.h:49
ThrottleLogger(uint64_t throttleMillis)
Constructs a logger with the specified throttle in milliseconds (throttleMillis).
Definition: ThrottleLogger.h:36
uint64_t millis(const Clock::time_point &now) const
Definition: ThrottleLogger.h:62
Definition: AddressExtractionExtension.cpp:28
uint32_t counter() const
Gets the total number of log attempts.
Definition: ThrottleLogger.h:43
std::lock_guard< SpinLock > SpinLockGuard
A spin lock guard.
Definition: SpinLock.h:60