Sunshine0.0.5917
Sunshine 0.0.5917
Self-hosted game stream host for Moonlight.
Loading...
Searching...
No Matches
logging Namespace Reference

Handles the initialization and deinitialization of the logging system. More...

Classes

class  deinit_t
 RAII helper that runs shutdown cleanup when destroyed. More...
class  min_max_avg_periodic_logger
 A helper class for tracking and logging numerical values across a period of time. More...
class  time_delta_periodic_logger
 A helper class for tracking and logging short time intervals across a period of time. More...

Functions

std::string bracket (const std::string &input)
 Enclose string in square brackets.
std::wstring bracket (const std::wstring &input)
 Enclose string in square brackets.
void deinit ()
 Deinitialize the logging system.
void formatter (const boost::log::record_view &view, boost::log::formatting_ostream &os)
 Format a Boost.Log record for Sunshine log output.
std::unique_ptr< deinit_t > init (int min_log_level, const std::string &log_file)
 Rotate the current log file and initialize the logging system.
void log_flush ()
 Flush the log.
void print_help (const char *name)
 Print help to stdout.
std::error_code rotate_log_file (const std::filesystem::path &log_file) noexcept
 Rotate a log file while retaining up to five previous logs.
void setup_av_logging (int min_log_level)
 Setup AV logging.
void setup_libdisplaydevice_logging (int min_log_level)
 Set up libdisplaydevice logging, clamping to its supported enum values.

Variables

constexpr std::size_t retained_log_file_count {5}
 The number of previous log files retained during rotation.

Detailed Description

Handles the initialization and deinitialization of the logging system.

Function Documentation

◆ bracket() [1/2]

std::string logging::bracket ( const std::string & input)

Enclose string in square brackets.

Parameters
inputInput string.
Returns
Enclosed string.

◆ bracket() [2/2]

std::wstring logging::bracket ( const std::wstring & input)

Enclose string in square brackets.

Parameters
inputInput string.
Returns
Enclosed string.

◆ deinit()

void logging::deinit ( )

Deinitialize the logging system.

Examples

void deinit()
Deinitialize the logging system.
Definition logging.cpp:59

◆ formatter()

void logging::formatter ( const boost::log::record_view & view,
boost::log::formatting_ostream & os )

Format a Boost.Log record for Sunshine log output.

Parameters
viewBoost.Log record view being formatted.
osBoost.Log output stream receiving formatted text.

◆ init()

std::unique_ptr< deinit_t > logging::init ( int min_log_level,
const std::string & log_file )
nodiscard

Rotate the current log file and initialize the logging system.

Parameters
min_log_levelThe minimum log level to output.
log_fileThe log file to write to.
Returns
An object that will deinitialize the logging system when it goes out of scope.

Examples

log_init(2, "sunshine.log");

◆ log_flush()

void logging::log_flush ( )

Flush the log.

Examples

void log_flush()
Flush the log.
Definition logging.cpp:260

◆ print_help()

void logging::print_help ( const char * name)

Print help to stdout.

Parameters
nameThe name of the program.

Examples

print_help("sunshine");
void print_help(const char *name)
Print help to stdout.
Definition logging.cpp:266

◆ rotate_log_file()

std::error_code logging::rotate_log_file ( const std::filesystem::path & log_file)
inlinenoexcept

Rotate a log file while retaining up to five previous logs.

The current log is renamed with a .1 suffix, existing rotated logs are advanced by one generation, and the previous .5 log is removed.

Parameters
log_filePath to the current log file.
Returns
An error code when rotation fails, or a clear error code on success.

◆ setup_av_logging()

void logging::setup_av_logging ( int min_log_level)

Setup AV logging.

Parameters
min_log_levelThe log level.

◆ setup_libdisplaydevice_logging()

void logging::setup_libdisplaydevice_logging ( int min_log_level)

Set up libdisplaydevice logging, clamping to its supported enum values.

Parameters
min_log_levelNumeric minimum severity, clamped from verbose through fatal.