20#include <boost/algorithm/string.hpp>
21#include <boost/lexical_cast.hpp>
47 using boost::algorithm::split;
48 using boost::algorithm::is_any_of;
49 using boost::algorithm::to_upper_copy;
50 using boost::lexical_cast;
51 using boost::bad_lexical_cast;
65 if (!tokens_str.empty())
67 vector<string> tokens;
69 result_pairs.reserve(tokens.size());
72 for (
const auto& token : tokens)
81 vector<string> leaf_tokens;
82 split(leaf_tokens, token, is_pair_sep);
84 if (leaf_tokens.empty() || (leaf_tokens.size() > 2))
88 "`-separated leaf tokens: `<component>",
96 if (leaf_tokens.size() == 1)
98 leaf_tokens.insert(leaf_tokens.begin(),
"");
104 leaf_tokens[0].clear();
113 assert(leaf_tokens.size() == 2);
123 sev = lexical_cast<Sev>(leaf_tokens[1]);
125 catch (
const bad_lexical_cast&)
128 "] in [", tokens_str,
"] must contain a severity composed of "
129 "alphanumerics and underscores but appears to contain other "
133 result_pairs.push_back
134 (make_pair<string, Sev>
135 (
string(to_upper_copy(leaf_tokens[0], locale::classic())),
142 if (result_pairs.empty() || (!result_pairs.front().first.empty()))
145 (result_pairs.begin(),
161 assert(target_config_ptr);
162 auto& target_config = *target_config_ptr;
175 const auto& component_name = pair.first;
176 const auto sev = pair.second;
178 if (component_name.empty())
180 target_config.configure_default_verbosity(sev,
false);
182 else if (!target_config.configure_component_verbosity_by_name(sev, component_name))
213 for (
size_t idx = 0; idx != component_sev_pairs.size(); ++idx)
215 const auto& pair = component_sev_pairs[idx];
216 const auto& component_name = pair.first;
222 if (idx != (component_sev_pairs.size() - 1))
Class used to configure the filtering and logging behavior of Loggers; its use in your custom Loggers...
static const Sev S_MOST_VERBOSE_SEV_DEFAULT
Recommended default/catch-all most-verbose-severity value if no specific config is given.
Optional-use structure encapsulating a full set of verbosity config, such that one can parse it from ...
const std::string & last_result_message() const
To be used after parse() or operator<< or apply_to_config(), returns "" on success or a message descr...
bool apply_to_config(Config *target_config)
Applies *this to to the given log::Config.
std::string m_last_result_message
See last_result_message().
Component_sev_pair_seq m_component_sev_pairs
See component_sev_pairs().
static const char S_TOKEN_SEPARATOR
Separates component/severity pairs in a Verbosity_config specifier string.
static const std::string S_ALL_COMPONENT_NAME_ALIAS
String that Verbosity_config::parse() treats as the default/catch-all verbosity's "component" specifi...
Verbosity_config()
Constructor a Verbosity_config that resets all severity config and sets the default/catch-all to Conf...
const Component_sev_pair_seq & component_sev_pairs() const
Read-only access to encapsulated config; specifies the verbosity-setting calls to make on a Config in...
std::vector< std::pair< std::string, Sev > > Component_sev_pair_seq
Short-hand for the configuration capable of being encapsulated by Verbosity_config.
bool parse(std::istream &is)
Deserializes *this from a standard input stream.
static const char S_PAIR_SEPARATOR
Separates component and severity within each pair in a Verbosity_config specifier string.
Flow module providing logging functionality.
std::ostream & operator<<(std::ostream &os, Sev val)
Serializes a log::Sev to a standard output stream.
std::istream & operator>>(std::istream &is, Sev &val)
Deserializes a log::Sev from a standard input stream.
Sev
Enumeration containing one of several message severity levels, ordered from highest to lowest.
bool operator==(const Verbosity_config &val1, const Verbosity_config &val2)
Checks for exact equality of two Verbosity_config objects.
bool operator!=(const Verbosity_config &val1, const Verbosity_config &val2)
Returns !(val1 == val2).
std::string ostream_op_string(T const &... ostream_args)
Equivalent to ostream_op_to_string() but returns a new string by value instead of writing to the call...