KDSPDSetup
Small library to initialize spdlog loggers from a toml configuration file.
KDSPDSetup::details Namespace Reference

This namespace contains implementation details and helpers used by functions in KDSPDSetup::setup. This includes lookup for sink types and spdlog enums, maps to contain named sinks, patterns, and thread pools (to be used when constructing loggers), and functions that actually construct sink pointers of specific types. More...

Classes

class  SPDMaps
 This class contains maps that associate string names to sink pointers, format strings, and thread pool information. This enables simple access of these objects by name when constructing loggers. There are no instances of the class - it is composed entirely of static members. More...
 

Functions

bool inTypelist (std::string const &typeStr, std::vector< std::string > const &strList)
 Returns true if a string typeStr is present in a vector strList, and false if not. Used to identify a group to which a sink's type belongs when reading from a configuration file. This grouping informs what additional fields should be extracted and narrows down which constructors to call to create a sink. More...
 
auto createRotatingFileSinkTuple (toml::table const &sinkTable, toml::string &&baseFilename, std::size_t const &maxFiles) -> std::tuple< toml::string const, std::size_t const, std::size_t const >
 Generates the argument list for rotating file sink constructor as a tuple and returns it. Given a TOML table representing a rotating file sink, a base filename, and a number of maximum files, extract and calculate the maximum file size from the table, and create a tuple with the base filename, max size, and max number of files in the correct order. Return this tuple so the values can be passed into the constructor for rotating file sink, in that order. More...
 
auto createFileSinkTuple (toml::table const &sinkTable, bool const &truncate) -> std::tuple< toml::string const, bool const >
 Generates the argument list for basic file sink constructor as a tuple and returns it. Given a TOML table representing a basic file sink and a boolean value for truncate, extract the filename from the table, and create a tuple with the filename and truncate in the order in which they will be passed into the basic file sink constructor. Return this tuple. More...
 
auto createDailyFileSinkTuple (toml::table &&sinkTable, bool const &truncate, toml::string &&baseFilename, uint16_t const &maxFiles) -> std::tuple< toml::string const, int const, int const, bool const, uint16_t const >
 Generates the argument list for daily file sink constructor as a tuple and returns it. Given a TOML table representing a basic file sink, a base filename, and a number of maximum files, and a boolean value for truncate, extract the rotation_hour and rotation_minute from the table, and create a tuple with the base filename, rotation hour, rotation minute, truncate, and maximum file count in the order in which they will be passed to the basic file sink constructor. Return this tuple. More...
 
auto createNullSinkPtr () -> std::shared_ptr< spdlog::sinks::null_sink< spdlog::details::null_mutex >>
 Create a null sink shared pointer and return it. More...
 
auto genFromFileStr (toml::string &&typeStr, toml::table &&sinkTable, bool const &truncate) -> spdlog::sink_ptr
 Return the result of calling KDSPDSetup::details::createFileSinkPtr with the correct template argument based on the value of typeStr. Uses macros createFileSinkStPtr and createFileSinkMtPtr for clarity. This function is called by KDSPDSetup::setup::handleTruncatableSink. More...
 
auto genFromRotateStr (toml::string &&typeStr, toml::table &&sinkTable, toml::string &&baseFilename, std::size_t const &maxFiles) -> spdlog::sink_ptr
 Return the result of calling KDSPDSetup::details::createRotatingFileSinkPtr with the correct template argument based on the value of typeStr. Uses macros createRotatingFileSinkStPtr and createRotatingFileSinkMtPtr for clarity. This function is called by KDSPDSetup::setup::handleMultipleFileSink. More...
 
auto genFromDailyStr (toml::string &&typeStr, toml::table &&sinkTable, bool const &truncate, toml::string &&baseFilename, uint16_t const &maxFiles) -> spdlog::sink_ptr
 Return the result of calling KDSPDSetup::details::createDailyFileSinkPtr with the correct template argument based on the value of typeStr. Uses macros createDailyFileSinkStPtr and createDailyFileSinkMtPtr for clarity. This function is called by KDSPDSetup::setup::handleMultipleFileSink. More...
 
auto genFromNullOrStdStr (toml::string &&typeStr) -> spdlog::sink_ptr
 Return the result of calling KDSPDSetup::details::createStdoutSinkPtr with the correct template argument or KDSPDSetup::details::createNullSinkPtr, based on the value of typeStr. Uses macros createStdoutSinkStPtr and createStdoutSinkMtPtr for clarity. This function is called by KDSPDSetup::setup::setupSink. More...
 
template<typename Mutex >
auto createRotatingFileSinkPtr (toml::table const &sinkTable, toml::string &&baseFilename, std::size_t const &maxFiles) -> std::shared_ptr< spdlog::sinks::rotating_file_sink< Mutex >>
 Create a rotating file sink shared pointer and return it. Calls KDSPDSetup::details::createRotatingFileSinkTuple to evaluate the arguments to pass into the constructor, and calls the constructor with those arguments. The macros createRotatingFileSinkStPtr and createRotatingFileSinkMtPtr exist to improve readability and clarity of intent when calling this function. More...
 
template<typename Mutex >
auto createFileSinkPtr (toml::table const &sinkTable, bool const &truncate) -> std::shared_ptr< spdlog::sinks::basic_file_sink< Mutex >>
 Create a basic file sink shared pointer and return it. Calls KDSPDSetup::details::createFileSinkTuple to evaluate the arguments to pass into the constructor, and calls the constructor with those arguments. The macros createFileSinkStPtr and createFileSinkMtPtr exist to improve readability and clarity of intent when calling this function. More...
 
template<typename Mutex >
auto createDailyFileSinkPtr (toml::table &&sinkTable, bool const &truncate, toml::string &&baseFilename, uint16_t const &maxFiles) -> std::shared_ptr< spdlog::sinks::daily_file_sink< Mutex >>
 Create a daily file sink shared pointer and return it. Calls KDSPDSetup::details::createDailyFileSinkTuple to evaluate the arguments to pass into the constructor, and calls the constructor with those arguments. The macros createDailyFileSinkStPtr and createDailyFileSinkMtPtr exist to improve readability and clarity of intent when calling this function. More...
 
template<typename Mutex >
auto createStdoutSinkPtr () -> std::shared_ptr< spdlog::sinks::stdout_sink< Mutex >>
 Create a standard output sink shared pointer and return it. The macros createStdoutSinkStPtr and createStdoutSinkMtPtr exist to improve readability and clarity of intent when calling this function. More...
 
template<typename Mutex >
auto createStderrSinkPtr () -> std::shared_ptr< spdlog::sinks::stderr_sink< Mutex >>
 
template<typename Mutex >
auto createStdoutColorSinkPtr () -> std::shared_ptr< spdlog::sinks::ansicolor_stdout_sink< Mutex >>
 Create an color standard output sink shared pointer and return it. The macros createStdoutColorSinkStPtr and createStdoutColorSinkMtPtr exist to improve readability and clarity of intent when calling this function. On Windows, the sink is a wincolor_stdout_sink, while on other platforms, it is an ansicolor_stdout_sink. More...
 
template<typename Mutex >
auto createStderrColorSinkPtr () -> std::shared_ptr< spdlog::sinks::ansicolor_stderr_sink< Mutex >>
 

Variables

static auto const stdStrs
 Vector of strings of spdlog standard output sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table. More...
 
static auto const fileStrs { std::vector<std::string>{ "basic_file_sink_st", "basic_file_sink_mt" } }
 Vector of strings of spdlog basic file sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table. More...
 
static auto const rotateStrs { std::vector<std::string>{ "rotating_file_sink_st", "rotating_file_sink_mt" } }
 Vector of strings of spdlog rotating file sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table. More...
 
static auto const dailyStrs { std::vector<std::string>{ "daily_file_sink_st", "daily_file_sink_mt" } }
 Vector of strings of spdlog daily file sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table. More...
 
static auto const nullStrs { std::vector<std::string>{ "null_sink_st", "null_sink_mt" } }
 Vector of strings of spdlog null sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table. More...
 
static auto const linuxStrs { std::vector<std::string>{ "syslog_sink_st", "syslog_sink_mt" } }
 Vector of strings of spdlog syslog sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table. More...
 
static auto const winStrs { std::vector<std::string>{ "msvc_sink_st", "msvc_sink_mt" } }
 Vector of strings of spdlog MSVC sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table. More...
 
static auto const levelMap
 A simple map associating strings of spdlog::level::level_enum names to the enums themselves. Used to pass an enum to spdlog::logger::set_level given a string read from a TOML table. More...
 
static auto const overflowMap
 A simple map associating strings of spdlog::async_overflow_policy names to the enums themselves. Used to pass an overflow policy to the constructor for an async logger given a string either read from a TOML table or set to the default "block". More...
 

Detailed Description

This namespace contains implementation details and helpers used by functions in KDSPDSetup::setup. This includes lookup for sink types and spdlog enums, maps to contain named sinks, patterns, and thread pools (to be used when constructing loggers), and functions that actually construct sink pointers of specific types.

Function Documentation

◆ createDailyFileSinkPtr()

template<typename Mutex >
auto KDSPDSetup::details::createDailyFileSinkPtr ( toml::table &&  sinkTable,
bool const &  truncate,
toml::string &&  baseFilename,
uint16_t const &  maxFiles 
) -> std::shared_ptr<spdlog::sinks::daily_file_sink<Mutex>>

Create a daily file sink shared pointer and return it. Calls KDSPDSetup::details::createDailyFileSinkTuple to evaluate the arguments to pass into the constructor, and calls the constructor with those arguments. The macros createDailyFileSinkStPtr and createDailyFileSinkMtPtr exist to improve readability and clarity of intent when calling this function.

Template Parameters
MutexThe template parameter to pass to the sink object. Will be either spdlog::details::null_mutex or std::mutex, for single-threaded or multi-threaded sinks respectively.
Parameters
sinkTabletoml11 table representation for a particular sink specified in a configuration file.
truncateThe value of truncate to pass into the constructor for daily file sink.
baseFilenameThe base filename to pass into the constructor for daily file sink.
maxFilesThe maximum number of files. This is passed into the constructor for daily file sink.
Returns
std::shared_ptr<spdlog::sinks::daily_file_sink<Mutex>> A daily file sink pointer that can be upcast to an spdlog::sink_ptr and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap.

Definition at line 439 of file details.h.

441 {
442  auto tup = createDailyFileSinkTuple(std::move(sinkTable), truncate, std::move(baseFilename), maxFiles);
443  return std::make_shared<spdlog::sinks::daily_file_sink<Mutex>>(std::get<0>(tup), std::get<1>(tup), std::get<2>(tup),
444  std::get<3>(tup), std::get<4>(tup));
445 }
auto createDailyFileSinkTuple(toml::table &&sinkTable, bool const &truncate, toml::string &&baseFilename, uint16_t const &maxFiles) -> std::tuple< toml::string const, int const, int const, bool const, uint16_t const >
Generates the argument list for daily file sink constructor as a tuple and returns it....
Definition: details.cpp:90
Here is the call graph for this function:

◆ createDailyFileSinkTuple()

auto KDSPDSetup::details::createDailyFileSinkTuple ( toml::table &&  sinkTable,
bool const &  truncate,
toml::string &&  baseFilename,
uint16_t const &  maxFiles 
) -> std::tuple< toml::string const, int const, int const, bool const, uint16_t const >

Generates the argument list for daily file sink constructor as a tuple and returns it. Given a TOML table representing a basic file sink, a base filename, and a number of maximum files, and a boolean value for truncate, extract the rotation_hour and rotation_minute from the table, and create a tuple with the base filename, rotation hour, rotation minute, truncate, and maximum file count in the order in which they will be passed to the basic file sink constructor. Return this tuple.

Parameters
sinkTabletoml11 table representation for a particular sink specified in a configuration file.
truncateThe value of truncate to pass into the constructor for daily file sink.
baseFilenameThe base filename to pass into the constructor for daily file sink.
maxFilesThe maximum number of files. This is passed into the constructor for daily file sink.
Returns
std::tuple<toml::string const, int const, int const, bool const, uint16_t const> A tuple containing the argument list for daily file sink constructor.

Definition at line 90 of file details.cpp.

93 {
94  auto rotationHour = static_cast<int>(sinkTable.at("rotation_hour").as_integer());
95  auto rotationMinute = static_cast<int>(sinkTable.at("rotation_minute").as_integer());
96 
97  return std::make_tuple(std::move(baseFilename), rotationHour, rotationMinute, truncate, maxFiles);
98 }
Here is the caller graph for this function:

◆ createFileSinkPtr()

template<typename Mutex >
auto KDSPDSetup::details::createFileSinkPtr ( toml::table const &  sinkTable,
bool const &  truncate 
) -> std::shared_ptr<spdlog::sinks::basic_file_sink<Mutex>>

Create a basic file sink shared pointer and return it. Calls KDSPDSetup::details::createFileSinkTuple to evaluate the arguments to pass into the constructor, and calls the constructor with those arguments. The macros createFileSinkStPtr and createFileSinkMtPtr exist to improve readability and clarity of intent when calling this function.

Template Parameters
MutexThe template parameter to pass to the sink object. Will be either spdlog::details::null_mutex or std::mutex, for single-threaded or multi-threaded sinks respectively.
Parameters
sinkTabletoml11 table representation for a particular sink specified in a configuration file.
truncateThe value of truncate to pass into the constructor for basic file sink.
Returns
std::shared_ptr<spdlog::sinks::basic_file_sink<Mutex>> A basic file sink pointer that can be upcast to an spdlog::sink_ptr and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap.

Definition at line 397 of file details.h.

399 {
400  auto tup = createFileSinkTuple(sinkTable, truncate);
401  return std::make_shared<spdlog::sinks::basic_file_sink<Mutex>>(std::get<0>(tup), std::get<1>(tup));
402 }
auto createFileSinkTuple(toml::table const &sinkTable, bool const &truncate) -> std::tuple< toml::string const, bool const >
Generates the argument list for basic file sink constructor as a tuple and returns it....
Definition: details.cpp:84
Here is the call graph for this function:

◆ createFileSinkTuple()

auto KDSPDSetup::details::createFileSinkTuple ( toml::table const &  sinkTable,
bool const &  truncate 
) -> std::tuple< toml::string const, bool const >

Generates the argument list for basic file sink constructor as a tuple and returns it. Given a TOML table representing a basic file sink and a boolean value for truncate, extract the filename from the table, and create a tuple with the filename and truncate in the order in which they will be passed into the basic file sink constructor. Return this tuple.

Parameters
sinkTabletoml11 table representation for a particular sink specified in a configuration file.
truncateThe value of truncate to pass into the constructor for basic file sink.
Returns
std::tuple<toml::string const, bool const> A tuple containing the argument list for basic file sink constructor.

Definition at line 84 of file details.cpp.

85 {
86  auto fileName = sinkTable.at("filename").as_string();
87  return std::make_tuple(std::move(fileName), truncate);
88 }
Here is the caller graph for this function:

◆ createNullSinkPtr()

auto KDSPDSetup::details::createNullSinkPtr ( ) -> std::shared_ptr< spdlog::sinks::null_sink< spdlog::details::null_mutex >>

Create a null sink shared pointer and return it.

Returns
std::shared_ptr<spdlog::sinks::null_sink<spdlog::details::null_mutex>> A null sink pointer that can be upcast to an spdlog::sink_ptr and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap.

Definition at line 100 of file details.cpp.

101 {
102  return std::make_shared<spdlog::sinks::null_sink<spdlog::details::null_mutex>>();
103 }
Here is the caller graph for this function:

◆ createRotatingFileSinkPtr()

template<typename Mutex >
auto KDSPDSetup::details::createRotatingFileSinkPtr ( toml::table const &  sinkTable,
toml::string &&  baseFilename,
std::size_t const &  maxFiles 
) -> std::shared_ptr<spdlog::sinks::rotating_file_sink<Mutex>>

Create a rotating file sink shared pointer and return it. Calls KDSPDSetup::details::createRotatingFileSinkTuple to evaluate the arguments to pass into the constructor, and calls the constructor with those arguments. The macros createRotatingFileSinkStPtr and createRotatingFileSinkMtPtr exist to improve readability and clarity of intent when calling this function.

Template Parameters
MutexThe template parameter to pass to the sink object. Will be either spdlog::details::null_mutex or std::mutex, for single-threaded or multi-threaded sinks respectively.
Parameters
sinkTabletoml11 table representation for a particular sink specified in a configuration file.
baseFilenameThe base filename to pass into the constructor for spdlog::sinks::rotating_file_sink.
maxFilesThe maximum number of files. This is passed into the constructor for spdlog::sinks::rotating_file_sink.
Returns
std::shared_ptr<spdlog::sinks::rotating_file_sink<Mutex>> A rotating file sink pointer that can be upcast to an spdlog::sink_ptr and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap.

Definition at line 361 of file details.h.

364 {
365  auto tup = createRotatingFileSinkTuple(sinkTable, std::move(baseFilename), maxFiles);
366  return std::make_shared<spdlog::sinks::rotating_file_sink<Mutex>>(std::get<0>(tup), std::get<1>(tup),
367  std::get<2>(tup));
368 }
auto createRotatingFileSinkTuple(toml::table const &sinkTable, toml::string &&baseFilename, std::size_t const &maxFiles) -> std::tuple< toml::string const, std::size_t const, std::size_t const >
Generates the argument list for rotating file sink constructor as a tuple and returns it....
Definition: details.cpp:44
Here is the call graph for this function:

◆ createRotatingFileSinkTuple()

auto KDSPDSetup::details::createRotatingFileSinkTuple ( toml::table const &  sinkTable,
toml::string &&  baseFilename,
std::size_t const &  maxFiles 
) -> std::tuple< toml::string const, std::size_t const, std::size_t const >

Generates the argument list for rotating file sink constructor as a tuple and returns it. Given a TOML table representing a rotating file sink, a base filename, and a number of maximum files, extract and calculate the maximum file size from the table, and create a tuple with the base filename, max size, and max number of files in the correct order. Return this tuple so the values can be passed into the constructor for rotating file sink, in that order.

Parameters
sinkTabletoml11 table representation for a particular sink specified in a configuration file.
baseFilenameThe base filename to later pass into the constructor for spdlog::sinks::rotating_file_sink.
maxFilesThe maximum number of files. This is later passed into the constructor for spdlog::sinks::rotating_file_sink.
Returns
std::tuple<toml::string const, std::size_t const, std::size_t const> A tuple containing the argument list for rotating file sink constructor.

Definition at line 44 of file details.cpp.

47 {
48  auto const maxSize = static_cast<std::string>(sinkTable.at("max_size").as_string());
49  auto const maxSizeStrBack = maxSize.back();
50  std::size_t maxSizeInt{};
51 
52  if (std::string{ "TGMK" }.find(maxSizeStrBack) != std::string::npos) {
53  auto const prefixStr = maxSize.substr(0, maxSize.size() - 1);
54  maxSizeInt = std::stoi(prefixStr);
55 
56  std::size_t constexpr kilo = 1024;
57  std::size_t constexpr mega = kilo * kilo;
58  std::size_t constexpr giga = mega * kilo;
59  std::size_t constexpr tera = giga * kilo;
60 
61  switch (maxSizeStrBack) {
62  case 'T':
63  maxSizeInt *= tera;
64  break;
65  case 'G':
66  maxSizeInt *= giga;
67  break;
68  case 'M':
69  maxSizeInt *= mega;
70  break;
71  case 'K':
72  maxSizeInt *= kilo;
73  break;
74  default:
75  break;
76  }
77  } else {
78  maxSizeInt = std::stoi(maxSize);
79  }
80 
81  return std::make_tuple(std::move(baseFilename), maxSizeInt, maxFiles);
82 }
Here is the caller graph for this function:

◆ createStderrColorSinkPtr()

template<typename Mutex >
auto KDSPDSetup::details::createStderrColorSinkPtr ( ) -> std::shared_ptr<spdlog::sinks::ansicolor_stderr_sink<Mutex>>

Definition at line 517 of file details.h.

518 {
519  return std::make_shared<spdlog::sinks::ansicolor_stderr_sink<Mutex>>();
520 }

◆ createStderrSinkPtr()

template<typename Mutex >
auto KDSPDSetup::details::createStderrSinkPtr ( ) -> std::shared_ptr<spdlog::sinks::stderr_sink<Mutex>>

Definition at line 471 of file details.h.

472 {
473  return std::make_shared<spdlog::sinks::stderr_sink<Mutex>>();
474 }

◆ createStdoutColorSinkPtr()

template<typename Mutex >
auto KDSPDSetup::details::createStdoutColorSinkPtr ( ) -> std::shared_ptr<spdlog::sinks::ansicolor_stdout_sink<Mutex>>

Create an color standard output sink shared pointer and return it. The macros createStdoutColorSinkStPtr and createStdoutColorSinkMtPtr exist to improve readability and clarity of intent when calling this function. On Windows, the sink is a wincolor_stdout_sink, while on other platforms, it is an ansicolor_stdout_sink.

Template Parameters
MutexThe template parameter to pass to the sink object. Will be either spdlog::details::console_nullmutex or spdlog::details::console_mutex, for single-threaded or multi-threaded sinks respectively.
Returns
std::shared_ptr<spdlog::sinks::ansicolor_stdout_sink<Mutex>> A color standard output sink pointer that can be upcast to an spdlog::sink_ptr and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap.

Definition at line 511 of file details.h.

512 {
513  return std::make_shared<spdlog::sinks::ansicolor_stdout_sink<Mutex>>();
514 }

◆ createStdoutSinkPtr()

template<typename Mutex >
auto KDSPDSetup::details::createStdoutSinkPtr ( ) -> std::shared_ptr<spdlog::sinks::stdout_sink<Mutex>>

Create a standard output sink shared pointer and return it. The macros createStdoutSinkStPtr and createStdoutSinkMtPtr exist to improve readability and clarity of intent when calling this function.

Template Parameters
MutexThe template parameter to pass to the sink object. Will be either spdlog::details::console_nullmutex or spdlog::details::console_mutex, for single-threaded or multi-threaded sinks respectively.
Returns
std::shared_ptr<spdlog::sinks::stdout_sink<Mutex>> A standard output sink pointer that can be upcast to an spdlog::sink_ptr and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap.

Definition at line 465 of file details.h.

466 {
467  return std::make_shared<spdlog::sinks::stdout_sink<Mutex>>();
468 }

◆ genFromDailyStr()

auto KDSPDSetup::details::genFromDailyStr ( toml::string &&  typeStr,
toml::table &&  sinkTable,
bool const &  truncate,
toml::string &&  baseFilename,
uint16_t const &  maxFiles 
) -> spdlog::sink_ptr

Return the result of calling KDSPDSetup::details::createDailyFileSinkPtr with the correct template argument based on the value of typeStr. Uses macros createDailyFileSinkStPtr and createDailyFileSinkMtPtr for clarity. This function is called by KDSPDSetup::setup::handleMultipleFileSink.

Parameters
typeStrA string of a typename of an spdlog sink.
sinkTabletoml11 table representation for a particular sink specified in a configuration file.
truncateThe value of truncate to pass into the constructor for daily file sink.
baseFilenameThe base filename to pass into the constructor for daily file sink.
maxFilesThe maximum number of files. This is passed into the constructor for daily file sink.
Returns
spdlog::sink_ptr The result of calling KDSPDSetup::details::createDailyFileSinkPtr.

Definition at line 147 of file details.cpp.

149 {
150  if (typeStr == "daily_file_sink_st") {
151  return createDailyFileSinkStPtr(std::move(sinkTable), truncate, std::move(baseFilename), maxFiles);
152  }
153  if (typeStr == "daily_file_sink_mt") {
154  return createDailyFileSinkMtPtr(std::move(sinkTable), truncate, std::move(baseFilename), maxFiles);
155  }
156 
157  return nullptr;
158 }
#define createDailyFileSinkStPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createDailyFileSinkPtr.
Definition: details.h:250
#define createDailyFileSinkMtPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createDailyFileSinkPtr.
Definition: details.h:256
Here is the caller graph for this function:

◆ genFromFileStr()

auto KDSPDSetup::details::genFromFileStr ( toml::string &&  typeStr,
toml::table &&  sinkTable,
bool const &  truncate 
) -> spdlog::sink_ptr

Return the result of calling KDSPDSetup::details::createFileSinkPtr with the correct template argument based on the value of typeStr. Uses macros createFileSinkStPtr and createFileSinkMtPtr for clarity. This function is called by KDSPDSetup::setup::handleTruncatableSink.

Parameters
typeStrA string of a typename of an spdlog sink.
sinkTabletoml11 table representation for a particular sink specified in a configuration file.
truncateThe value of truncate to pass into the constructor for basic file sink.
Returns
spdlog::sink_ptr The result of calling KDSPDSetup::details::createFileSinkPtr.

Definition at line 122 of file details.cpp.

123 {
124  if (typeStr == "basic_file_sink_st") {
125  return createFileSinkStPtr(sinkTable, truncate);
126  }
127  if (typeStr == "basic_file_sink_mt") {
128  return createFileSinkMtPtr(sinkTable, truncate);
129  }
130 
131  return nullptr;
132 }
#define createFileSinkMtPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createFileSinkPtr.
Definition: details.h:244
#define createFileSinkStPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createFileSinkPtr.
Definition: details.h:238
Here is the caller graph for this function:

◆ genFromNullOrStdStr()

auto KDSPDSetup::details::genFromNullOrStdStr ( toml::string &&  typeStr) -> spdlog::sink_ptr

Return the result of calling KDSPDSetup::details::createStdoutSinkPtr with the correct template argument or KDSPDSetup::details::createNullSinkPtr, based on the value of typeStr. Uses macros createStdoutSinkStPtr and createStdoutSinkMtPtr for clarity. This function is called by KDSPDSetup::setup::setupSink.

Parameters
typeStrA string of a typename of an spdlog sink.
Returns
spdlog::sink_ptr The result of calling KDSPDSetup::details::createStdoutSinkPtr or KDSPDSetup::details::createNullSinkPtr.

Definition at line 160 of file details.cpp.

161 {
162  if (typeStr == "null_sink_st" || typeStr == "null_sink_mt") {
163  return createNullSinkPtr();
164  }
165  if (typeStr == "stdout_sink_st") {
166  return createStdoutSinkStPtr();
167  }
168  if (typeStr == "stdout_sink_mt") {
169  return createStdoutSinkMtPtr();
170  }
171  if (typeStr == "stdout_color_sink_st" || typeStr == "color_stdout_sink_st") {
173  }
174  if (typeStr == "stdout_color_sink_mt" || typeStr == "color_stdout_sink_mt") {
176  }
177  if (typeStr == "stderr_sink_st") {
178  return createStderrSinkStPtr();
179  }
180  if (typeStr == "stderr_sink_mt") {
181  return createStderrSinkMtPtr();
182  }
183  if (typeStr == "stderr_color_sink_st" || typeStr == "color_stderr_sink_st") {
185  }
186  if (typeStr == "stderr_color_sink_mt" || typeStr == "color_stderr_sink_mt") {
188  }
189 
190  return nullptr;
191 }
#define createStderrColorSinkStPtr
Definition: details.h:285
#define createStdoutSinkMtPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createStdoutSinkPtr.
Definition: details.h:268
#define createStdoutColorSinkStPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createStdoutColorSinkPtr.
Definition: details.h:277
#define createStderrSinkStPtr
Definition: details.h:270
#define createStdoutColorSinkMtPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createStdoutColorSinkPtr.
Definition: details.h:283
#define createStderrSinkMtPtr
Definition: details.h:271
#define createStderrColorSinkMtPtr
Definition: details.h:286
#define createStdoutSinkStPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createStdoutSinkPtr.
Definition: details.h:262
auto createNullSinkPtr() -> std::shared_ptr< spdlog::sinks::null_sink< spdlog::details::null_mutex >>
Create a null sink shared pointer and return it.
Definition: details.cpp:100
Here is the call graph for this function:
Here is the caller graph for this function:

◆ genFromRotateStr()

auto KDSPDSetup::details::genFromRotateStr ( toml::string &&  typeStr,
toml::table &&  sinkTable,
toml::string &&  baseFilename,
std::size_t const &  maxFiles 
) -> spdlog::sink_ptr

Return the result of calling KDSPDSetup::details::createRotatingFileSinkPtr with the correct template argument based on the value of typeStr. Uses macros createRotatingFileSinkStPtr and createRotatingFileSinkMtPtr for clarity. This function is called by KDSPDSetup::setup::handleMultipleFileSink.

Parameters
typeStrA string of a typename of an spdlog sink.
sinkTabletoml11 table representation for a particular sink specified in a configuration file.
baseFilenameThe base filename to pass into the constructor for rotating file sink.
maxFilesThe maximum number of files. This is passed into the constructor for rotating file sink.
Returns
spdlog::sink_ptr The result of calling KDSPDSetup::details::createRotatingFileSinkPtr.

Definition at line 134 of file details.cpp.

136 {
137  if (typeStr == "rotating_file_sink_st") {
138  return createRotatingFileSinkStPtr(std::move(sinkTable), std::move(baseFilename), maxFiles);
139  }
140  if (typeStr == "rotating_file_sink_mt") {
141  return createRotatingFileSinkMtPtr(std::move(sinkTable), std::move(baseFilename), maxFiles);
142  }
143 
144  return nullptr;
145 }
#define createRotatingFileSinkStPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createRotatingFileSinkPtr.
Definition: details.h:226
#define createRotatingFileSinkMtPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createRotatingFileSinkPtr.
Definition: details.h:232
Here is the caller graph for this function:

◆ inTypelist()

bool KDSPDSetup::details::inTypelist ( std::string const &  typeStr,
std::vector< std::string > const &  strList 
)

Returns true if a string typeStr is present in a vector strList, and false if not. Used to identify a group to which a sink's type belongs when reading from a configuration file. This grouping informs what additional fields should be extracted and narrows down which constructors to call to create a sink.

Parameters
typeStrA string of a typename of an spdlog sink.
strListA vector of typename strings to match against.
Returns
true if strList contains typeStr.
false if strList does not contain typeStr.

Definition at line 39 of file details.cpp.

40 {
41  return std::find(strList.cbegin(), strList.cend(), typeStr) != std::cend(strList);
42 }
Here is the caller graph for this function:

Variable Documentation

◆ dailyStrs

auto const KDSPDSetup::details::dailyStrs { std::vector<std::string>{ "daily_file_sink_st", "daily_file_sink_mt" } }
static

Vector of strings of spdlog daily file sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table.

Definition at line 73 of file details.h.

◆ fileStrs

auto const KDSPDSetup::details::fileStrs { std::vector<std::string>{ "basic_file_sink_st", "basic_file_sink_mt" } }
static

Vector of strings of spdlog basic file sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table.

Definition at line 59 of file details.h.

◆ levelMap

auto const KDSPDSetup::details::levelMap
static
Initial value:
{ std::unordered_map<std::string, spdlog::level::level_enum>{
{ "critical", spdlog::level::level_enum::critical },
{ "debug", spdlog::level::level_enum::debug },
{ "err", spdlog::level::level_enum::err },
{ "info", spdlog::level::level_enum::info },
{ "n_levels", spdlog::level::level_enum::n_levels },
{ "off", spdlog::level::level_enum::off },
{ "trace", spdlog::level::level_enum::trace },
{ "warn", spdlog::level::level_enum::warn },
} }

A simple map associating strings of spdlog::level::level_enum names to the enums themselves. Used to pass an enum to spdlog::logger::set_level given a string read from a TOML table.

Definition at line 101 of file details.h.

◆ linuxStrs

auto const KDSPDSetup::details::linuxStrs { std::vector<std::string>{ "syslog_sink_st", "syslog_sink_mt" } }
static

Vector of strings of spdlog syslog sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table.

Definition at line 87 of file details.h.

◆ nullStrs

auto const KDSPDSetup::details::nullStrs { std::vector<std::string>{ "null_sink_st", "null_sink_mt" } }
static

Vector of strings of spdlog null sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table.

Definition at line 80 of file details.h.

◆ overflowMap

auto const KDSPDSetup::details::overflowMap
static
Initial value:
{ std::map<toml::string, spdlog::async_overflow_policy>{
{ "overrun_oldest", spdlog::async_overflow_policy::overrun_oldest },
{ "block", spdlog::async_overflow_policy::block },
} }

A simple map associating strings of spdlog::async_overflow_policy names to the enums themselves. Used to pass an overflow policy to the constructor for an async logger given a string either read from a TOML table or set to the default "block".

Definition at line 118 of file details.h.

◆ rotateStrs

auto const KDSPDSetup::details::rotateStrs { std::vector<std::string>{ "rotating_file_sink_st", "rotating_file_sink_mt" } }
static

Vector of strings of spdlog rotating file sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table.

Definition at line 66 of file details.h.

◆ stdStrs

auto const KDSPDSetup::details::stdStrs
static
Initial value:
{ std::vector<std::string>{ "stdout_sink_st", "stdout_sink_mt", "stdout_color_sink_st",
"stdout_color_sink_mt", "color_stdout_sink_st",
"color_stdout_sink_mt", "stderr_sink_st", "stderr_sink_mt",
"stderr_color_sink_st", "stderr_color_sink_mt",
"color_stderr_sink_st", "color_stderr_sink_mt" } }

Vector of strings of spdlog standard output sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table.

Definition at line 48 of file details.h.

◆ winStrs

auto const KDSPDSetup::details::winStrs { std::vector<std::string>{ "msvc_sink_st", "msvc_sink_mt" } }
static

Vector of strings of spdlog MSVC sink typenames. Used when matching a type string from a TOML table to determine what additional type-specific fields should be read from the table.

Definition at line 94 of file details.h.