Sunshine master
Self-hosted game stream host for Moonlight.
logging::time_delta_periodic_logger Class Reference

A helper class for tracking and logging short time intervals across a period of time. More...

#include <src/logging.h>

Public Member Functions

void first_point (const std::chrono::steady_clock::time_point &point)
 Store the first timestamp for a measured interval.
 
void first_point_now ()
 Store the current time as the first timestamp.
 
bool is_enabled () const
 Check whether this periodic logger should emit at the configured severity.
 
void reset ()
 Reset the object to its initial empty state.
 
void second_point_and_log (const std::chrono::steady_clock::time_point &point)
 Store the second timestamp and log the elapsed interval.
 
void second_point_now_and_log ()
 Store the current time as the second timestamp and log the elapsed interval.
 
 time_delta_periodic_logger (boost::log::sources::severity_logger< int > &severity, std::string_view message, std::chrono::seconds interval_in_seconds=std::chrono::seconds(20))
 Construct a periodic logger for elapsed-time samples.
 

Detailed Description

A helper class for tracking and logging short time intervals across a period of time.

*Examples**

time_delta_periodic_logger logger(debug, "Test duration", 5s);
logger.first_point_now();
// ...
logger.second_point_now_and_log();
// after 5 seconds
logger.first_point_now();
// ...
logger.second_point_now_and_log();
// In the log:
// [2024:01:01:12:00:00]: Debug: Test duration (min/max/avg): 1.23ms/3.21ms/2.31ms
A helper class for tracking and logging short time intervals across a period of time.
Definition logging.h:204
bl::sources::severity_logger< int > debug
Follow what is happening.
Definition logging.cpp:41

Constructor & Destructor Documentation

◆ time_delta_periodic_logger()

logging::time_delta_periodic_logger::time_delta_periodic_logger ( boost::log::sources::severity_logger< int > & severity,
std::string_view message,
std::chrono::seconds interval_in_seconds = std::chrono::seconds(20) )
inline

Construct a periodic logger for elapsed-time samples.

Parameters
severitySeverity level associated with the log message.
messageMessage text to log or report.
interval_in_secondsInterval in seconds.

Member Function Documentation

◆ first_point()

void logging::time_delta_periodic_logger::first_point ( const std::chrono::steady_clock::time_point & point)
inline

Store the first timestamp for a measured interval.

Parameters
pointTime point used for elapsed-time calculations.

◆ is_enabled()

bool logging::time_delta_periodic_logger::is_enabled ( ) const
inline

Check whether this periodic logger should emit at the configured severity.

Returns
True when the logger severity is enabled and sampling should continue.

◆ second_point_and_log()

void logging::time_delta_periodic_logger::second_point_and_log ( const std::chrono::steady_clock::time_point & point)
inline

Store the second timestamp and log the elapsed interval.

Parameters
pointTime point used for elapsed-time calculations.

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