25#include <unordered_map>
28#include <toml++/toml.h>
34namespace msgpack_rpc::config::toml::impl {
45 const ::toml::source_region& source, std::string_view config_key) {
61 if (str ==
"critical") {
74 for (
const auto& [key, value] : table) {
75 const auto key_str = key.str();
76 if (key_str ==
"file_path") {
78 }
else if (key_str ==
"max_file_size") {
80 "max_file_size", max_file_size, std::size_t);
81 }
else if (key_str ==
"max_files") {
83 }
else if (key_str ==
"output_log_level") {
84 const auto config_value = value.value<std::string>();
89 *config_value, value.source(),
"output_log_level"));
101 std::unordered_map<std::string, LoggingConfig>& configs) {
102 for (
const auto& [key, value] : table) {
103 const auto* table_ptr = value.as_table();
104 if (table_ptr ==
nullptr) {
106 "\"logging\" must be a table of tables.");
110 configs.try_emplace(std::string(key.str()), std::move(
config));
Class of Logging configuration.
Definition of LogLevel enumeration.
Definition of LoggingConfig class.
Namespace of configurations.
LogLevel
Enumeration of log levels.
@ TRACE
Trace. (Internal operations to send and receive messages.)
@ WARN
Warnings. (Unexpected conditions which don't stop operations.)
@ INFO
Information. (Not used in this library.)
@ CRITICAL
Critical. (Unexpected conditions which can stop all operations in communication.)
@ ERROR
Error. (Unexpected conditions which stop some operations in communication.)
@ DEBUG
Debug. (Log of messages, initialization and finalization of clients and servers.)
void parse_toml(const ::toml::table &table, MessageParserConfig &config)
Parse a configuration of parsers of messages from TOML.
Definition of common functions and macros to parse TOML files.
#define MSGPACK_RPC_PARSE_TOML_VALUE(KEY_STR, CONFIG_FUNCTION, TYPE)
Internal macro to parse a value from TOML.
void throw_error(const ::toml::source_region &source, std::string_view config_key)
Throw an exception for an error of TOML.
logging::LogLevel parse_log_level(std::string_view str, const ::toml::source_region &source, std::string_view config_key)
Parse a log level from a string.