KDSPDSetup
Small library to initialize spdlog loggers from a toml configuration file.
|
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... | |
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.
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.
Mutex | The 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. |
sinkTable | toml11 table representation for a particular sink specified in a configuration file. |
truncate | The value of truncate to pass into the constructor for daily file sink. |
baseFilename | The base filename to pass into the constructor for daily file sink. |
maxFiles | The maximum number of files. This is passed into the constructor for daily file sink. |
spdlog::sink_ptr
and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap. Definition at line 439 of file details.h.
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.
sinkTable | toml11 table representation for a particular sink specified in a configuration file. |
truncate | The value of truncate to pass into the constructor for daily file sink. |
baseFilename | The base filename to pass into the constructor for daily file sink. |
maxFiles | The maximum number of files. This is passed into the constructor for daily file sink. |
Definition at line 90 of file details.cpp.
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.
Mutex | The 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. |
sinkTable | toml11 table representation for a particular sink specified in a configuration file. |
truncate | The value of truncate to pass into the constructor for basic file sink. |
spdlog::sink_ptr
and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap. Definition at line 397 of file details.h.
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.
sinkTable | toml11 table representation for a particular sink specified in a configuration file. |
truncate | The value of truncate to pass into the constructor for basic file sink. |
Definition at line 84 of file details.cpp.
auto KDSPDSetup::details::createNullSinkPtr | ( | ) | -> std::shared_ptr< spdlog::sinks::null_sink< spdlog::details::null_mutex >> |
Create a null sink shared pointer and return it.
spdlog::sink_ptr
and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap. Definition at line 100 of file details.cpp.
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.
Mutex | The 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. |
sinkTable | toml11 table representation for a particular sink specified in a configuration file. |
baseFilename | The base filename to pass into the constructor for spdlog::sinks::rotating_file_sink . |
maxFiles | The maximum number of files. This is passed into the constructor for spdlog::sinks::rotating_file_sink . |
spdlog::sink_ptr
and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap. Definition at line 361 of file details.h.
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.
sinkTable | toml11 table representation for a particular sink specified in a configuration file. |
baseFilename | The base filename to later pass into the constructor for spdlog::sinks::rotating_file_sink . |
maxFiles | The maximum number of files. This is later passed into the constructor for spdlog::sinks::rotating_file_sink . |
Definition at line 44 of file details.cpp.
auto KDSPDSetup::details::createStderrColorSinkPtr | ( | ) | -> std::shared_ptr<spdlog::sinks::ansicolor_stderr_sink<Mutex>> |
auto KDSPDSetup::details::createStderrSinkPtr | ( | ) | -> std::shared_ptr<spdlog::sinks::stderr_sink<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
.
Mutex | The 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. |
spdlog::sink_ptr
and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap. 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.
Mutex | The 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. |
spdlog::sink_ptr
and added to an entry in KDSPDSetup::details::SPDMaps::mSinkMap. 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.
typeStr | A string of a typename of an spdlog sink. |
sinkTable | toml11 table representation for a particular sink specified in a configuration file. |
truncate | The value of truncate to pass into the constructor for daily file sink. |
baseFilename | The base filename to pass into the constructor for daily file sink. |
maxFiles | The maximum number of files. This is passed into the constructor for daily file sink. |
Definition at line 147 of file details.cpp.
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.
typeStr | A string of a typename of an spdlog sink. |
sinkTable | toml11 table representation for a particular sink specified in a configuration file. |
truncate | The value of truncate to pass into the constructor for basic file sink. |
Definition at line 122 of file details.cpp.
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.
typeStr | A string of a typename of an spdlog sink. |
Definition at line 160 of file details.cpp.
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.
typeStr | A string of a typename of an spdlog sink. |
sinkTable | toml11 table representation for a particular sink specified in a configuration file. |
baseFilename | The base filename to pass into the constructor for rotating file sink. |
maxFiles | The maximum number of files. This is passed into the constructor for rotating file sink. |
Definition at line 134 of file details.cpp.
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.
typeStr | A string of a typename of an spdlog sink. |
strList | A vector of typename strings to match against. |
strList
contains typeStr
. strList
does not contain typeStr
. Definition at line 39 of file details.cpp.
|
static |
|
static |
|
static |
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.
|
static |
|
static |
|
static |
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"
.
|
static |
|
static |
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.
|
static |