CatapultServer  v0.5.0.1 (Elephant)
catapult::utils::ThrottleLogger Class Reference
Collaboration diagram for catapult::utils::ThrottleLogger:

Public Member Functions

 ThrottleLogger (uint64_t throttleMillis)
 Constructs a logger with the specified throttle in milliseconds (throttleMillis). More...
 
uint32_t counter () const
 Gets the total number of log attempts. More...
 
bool isThrottled ()
 Returns false if a log should be output. More...
 

Private Types

using Clock = std::chrono::steady_clock
 

Private Member Functions

uint64_t millis (const Clock::time_point &now) const
 

Private Attributes

uint64_t m_throttleMillis
 
std::atomic< uint32_t > m_counter
 
Clock::time_point m_last
 
utils::SpinLock m_lock
 

Detailed Description

Simple throttle logger.

Note
Instances need to be threadsafe due to usage in CATAPULT_LOG_THROTTLE.

Member Typedef Documentation

◆ Clock

using catapult::utils::ThrottleLogger::Clock = std::chrono::steady_clock
private

Constructor & Destructor Documentation

◆ ThrottleLogger()

catapult::utils::ThrottleLogger::ThrottleLogger ( uint64_t  throttleMillis)
inlineexplicit

Constructs a logger with the specified throttle in milliseconds (throttleMillis).

Member Function Documentation

◆ counter()

uint32_t catapult::utils::ThrottleLogger::counter ( ) const
inline

Gets the total number of log attempts.

◆ isThrottled()

bool catapult::utils::ThrottleLogger::isThrottled ( )
inline

Returns false if a log should be output.

Here is the call graph for this function:

◆ millis()

uint64_t catapult::utils::ThrottleLogger::millis ( const Clock::time_point &  now) const
inlineprivate
Here is the caller graph for this function:

Member Data Documentation

◆ m_counter

std::atomic<uint32_t> catapult::utils::ThrottleLogger::m_counter
private

◆ m_last

Clock::time_point catapult::utils::ThrottleLogger::m_last
private

◆ m_lock

utils::SpinLock catapult::utils::ThrottleLogger::m_lock
private

◆ m_throttleMillis

uint64_t catapult::utils::ThrottleLogger::m_throttleMillis
private

The documentation for this class was generated from the following file: