24 return mThreadPoolMap;
39 bool inTypelist(std::string
const &typeStr, std::vector<std::string>
const &strList)
41 return std::find(strList.cbegin(), strList.cend(), typeStr) != std::cend(strList);
45 std::size_t
const &maxFiles)
46 -> std::tuple<toml::string const, std::size_t const, std::size_t const>
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{};
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);
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;
61 switch (maxSizeStrBack) {
78 maxSizeInt = std::stoi(maxSize);
81 return std::make_tuple(std::move(baseFilename), maxSizeInt, maxFiles);
84 auto createFileSinkTuple(toml::table
const &sinkTable,
bool const &truncate) -> std::tuple<toml::string const, bool const>
86 auto fileName = sinkTable.at(
"filename").as_string();
87 return std::make_tuple(std::move(fileName), truncate);
91 uint16_t
const &maxFiles)
92 -> std::tuple<toml::string const, int const, int const, bool const, uint16_t const>
94 auto rotationHour =
static_cast<int>(sinkTable.at(
"rotation_hour").as_integer());
95 auto rotationMinute =
static_cast<int>(sinkTable.at(
"rotation_minute").as_integer());
97 return std::make_tuple(std::move(baseFilename), rotationHour, rotationMinute, truncate, maxFiles);
100 auto createNullSinkPtr() -> std::shared_ptr<spdlog::sinks::null_sink<spdlog::details::null_mutex>>
102 return std::make_shared<spdlog::sinks::null_sink<spdlog::details::null_mutex>>();
106 auto createSyslogSinkTuple(toml::table
const &sinkTable)
107 -> std::tuple<toml::string const, int const, int const, bool const>
109 auto ident = (sinkTable.contains(
"ident")) ? sinkTable.at(
"ident").as_string() :
"";
111 auto syslogOption = (sinkTable.contains(
"syslog_option")) ?
static_cast<int>(sinkTable.at(
"syslog_option").as_integer()) :
int{ 0 };
113 auto syslogFacility =
114 (sinkTable.contains(
"syslog_facility")) ?
static_cast<int>(sinkTable.at(
"syslog_facility").as_integer()) : LOG_USER;
116 bool enableFormatting =
true;
118 return std::make_tuple(std::move(ident), syslogOption, syslogFacility, enableFormatting);
122 auto genFromFileStr(toml::string &&typeStr, toml::table &&sinkTable,
bool const &truncate) -> spdlog::sink_ptr
124 if (typeStr ==
"basic_file_sink_st") {
127 if (typeStr ==
"basic_file_sink_mt") {
134 auto genFromRotateStr(toml::string &&typeStr, toml::table &&sinkTable, toml::string &&baseFilename,
135 std::size_t
const &maxFiles) -> spdlog::sink_ptr
137 if (typeStr ==
"rotating_file_sink_st") {
140 if (typeStr ==
"rotating_file_sink_mt") {
147 auto genFromDailyStr(toml::string &&typeStr, toml::table &&sinkTable,
bool const &truncate,
148 toml::string &&baseFilename, uint16_t
const &maxFiles) -> spdlog::sink_ptr
150 if (typeStr ==
"daily_file_sink_st") {
153 if (typeStr ==
"daily_file_sink_mt") {
162 if (typeStr ==
"null_sink_st" || typeStr ==
"null_sink_mt") {
165 if (typeStr ==
"stdout_sink_st") {
168 if (typeStr ==
"stdout_sink_mt") {
171 if (typeStr ==
"stdout_color_sink_st" || typeStr ==
"color_stdout_sink_st") {
174 if (typeStr ==
"stdout_color_sink_mt" || typeStr ==
"color_stdout_sink_mt") {
177 if (typeStr ==
"stderr_sink_st") {
180 if (typeStr ==
"stderr_sink_mt") {
183 if (typeStr ==
"stderr_color_sink_st" || typeStr ==
"color_stderr_sink_st") {
186 if (typeStr ==
"stderr_color_sink_mt" || typeStr ==
"color_stderr_sink_mt") {
194 auto genFromLinuxStr(toml::string &&typeStr, toml::table &&sinkTable) -> spdlog::sink_ptr
196 if (typeStr ==
"syslog_sink_st") {
197 return createSyslogSinkStPtr(std::move(sinkTable));
199 if (typeStr ==
"syslog_sink_mt") {
200 return createSyslogSinkMtPtr(std::move(sinkTable));
206 auto genFromWinStr(toml::string &&typeStr) -> spdlog::sink_ptr
208 if (typeStr ==
"msvc_sink_st") {
209 return createMsvcSinkStPtr();
211 if (typeStr ==
"msvc_sink_mt") {
212 return createMsvcSinkMtPtr();
static std::map< toml::string, spdlog::sink_ptr > mSinkMap
Map that associates string names to sink pointers. When sink pointers are created from sink tables in...
static void emplaceSinkMap(std::pair< toml::string, spdlog::sink_ptr > &&_pr)
Emplace a pair in the private member KDSPDSetup::details::SPDMaps::mSinkMap. This function is called ...
static std::map< toml::string, std::pair< std::size_t, std::size_t > > mThreadPoolMap
Map that associates string names to pairs of thread pool fields. The pairs represent the queue size a...
static auto sinkMap() -> std::map< toml::string, spdlog::sink_ptr > const &
Getter method for the private member KDSPDSetup::details::SPDMaps::mSinkMap. Used to index the map an...
static auto patternMap() -> std::map< toml::string, toml::string > const &
Getter method for the private member KDSPDSetup::details::SPDMaps::mPatternMap. Used to index the map...
static auto threadPoolMap() -> std::map< toml::string, std::pair< std::size_t, std::size_t >> const &
Getter method for the private member KDSPDSetup::details::SPDMaps::mThreadPoolMap....
static void emplaceThreadPoolMap(std::pair< toml::string, std::pair< std::size_t, std::size_t >> &&_pr)
Emplace a pair in the private member KDSPDSetup::details::SPDMaps::mThreadPoolMap....
static void emplacePatternMap(std::pair< toml::string, toml::string > &&_pr)
Emplace a pair in the private member KDSPDSetup::details::SPDMaps::mSinkMap. This function is called ...
static std::map< toml::string, toml::string > mPatternMap
Map that associates string names to pattern strings. When pattern tables are read from a configuratio...
#define createRotatingFileSinkStPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createRotatingFileSinkPtr.
#define createRotatingFileSinkMtPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createRotatingFileSinkPtr.
#define createStderrColorSinkStPtr
#define createFileSinkMtPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createFileSinkPtr.
#define createStdoutSinkMtPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createStdoutSinkPtr.
#define createStdoutColorSinkStPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createStdoutColorSinkPtr.
#define createStderrSinkStPtr
#define createStdoutColorSinkMtPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createStdoutColorSinkPtr.
#define createDailyFileSinkStPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createDailyFileSinkPtr.
#define createFileSinkStPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createFileSinkPtr.
#define createStderrSinkMtPtr
#define createStderrColorSinkMtPtr
#define createStdoutSinkStPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createStdoutSinkPtr.
#define createDailyFileSinkMtPtr
A macro alias to improve readability of calls to KDSPDSetup::details::createDailyFileSinkPtr.
This namespace contains implementation details and helpers used by functions in KDSPDSetup::setup....
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 ar...
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....
auto createNullSinkPtr() -> std::shared_ptr< spdlog::sinks::null_sink< spdlog::details::null_mutex >>
Create a null sink shared pointer and return it.
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....
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 argumen...
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...
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....
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....
auto genFromNullOrStdStr(toml::string &&typeStr) -> spdlog::sink_ptr
Return the result of calling KDSPDSetup::details::createStdoutSinkPtr with the correct template argum...