20#include <boost/algorithm/string.hpp>
32 m_use_human_friendly_time_stamps(true),
33 m_verbosity_default(
raw_sev_t(most_verbose_sev_default))
57 using std::memory_order_relaxed;
111 using std::memory_order_relaxed;
120 ++component_union_idx)
150 if (component.
empty())
166 os << component_union_idx;
170 auto& name = component_name_it->second;
171 assert(!name.empty());
179 using std::memory_order_relaxed;
187 return sev <= sev_override;
193 if (!component.
empty())
210 const auto most_verbose_sev_raw
215 if (most_verbose_sev_raw !=
raw_sev_t(-1))
217 return sev <=
Sev(most_verbose_sev_raw);
235 using boost::algorithm::to_upper_copy;
239 return to_upper_copy(
string(name), locale::classic());
244 using boost::algorithm::to_upper;
247 to_upper(*name, locale::classic());
253 return &verbosity_override;
274 std::atomic<
raw_sev_t>(src.load(std::memory_order_relaxed))
A light-weight class, each object storing a component payload encoding an enum value from enum type o...
bool empty() const
Returns true if *this is as if default-constructed (a null Component); false if as if constructed via...
enum_raw_t payload_enum_raw_value() const
Returns the numeric value of the enum payload stored by this Component, originating in the one-arg co...
std::type_index payload_type_index() const
Convenience accessor that returns std::type_index(payload_type()), which can be used most excellently...
Trivial wrapper of atomic<raw_sev_t> which adds a couple of things to make it possible to construct,...
Atomic_raw_sev(raw_sev_t init_val=raw_sev_t(-1))
Constructs the atomic to the given value, guaranteed to be load()ed as such in all subsequent accesse...
Class used to configure the filtering and logging behavior of Loggers; its use in your custom Loggers...
Config(Sev most_verbose_sev_default=S_MOST_VERBOSE_SEV_DEFAULT)
Constructs a conceptually blank but functional set of Config.
static void normalize_component_name(std::string *name)
Normalizes given component name in place.
bool configure_component_verbosity_by_name(Sev most_verbose_sev, util::String_view component_name)
Like configure_component_verbosity(), but the component is to be specified by its registered string n...
Component_union_idx_to_name_map m_component_names_by_union_idx
Maps each flat union component index to its output component name as registered in init_component_nam...
Atomic_raw_sev m_verbosity_default
Most verbose (highest) log::Sev for which output_whether_should_log() will return true,...
static std::string normalized_component_name(util::String_view name)
Normalized version of given component name.
bool output_component_to_ostream(std::ostream *os, const Component &component) const
An output of Config, this writes a string representation of the given component value to the given os...
Component_union_idx_to_sev_map m_verbosities_by_component
Maps from flat union component index to most verbose (highest) log::Sev for which output_whether_shou...
static Sev * this_thread_verbosity_override()
Returns pointer to this thread's mutable verbosity override, for querying or assignment alike.
static const Sev S_MOST_VERBOSE_SEV_DEFAULT
Recommended default/catch-all most-verbose-severity value if no specific config is given.
Component::enum_raw_t component_union_idx_t
Unsigned index into the flat union of component tables maintained by a Config, combining potentially ...
static util::Scoped_setter< Sev > this_thread_verbosity_override_auto(Sev most_verbose_sev_or_none)
Sets *(this_thread_verbosity_override()) = most_verbose_sev_or_none; and returns an object that shall...
void configure_default_verbosity(Sev most_verbose_sev_default, bool reset)
Sets the default verbosity to the given value, to be used by subsequent output_whether_should_log() c...
uint8_t raw_sev_t
How we store a log::Sev (a mere enum itself) in a certain data structure.
Component_name_to_union_idx_map m_component_union_idxs_by_name
Maps each distinct component name as registered in init_component_names() to its flat union component...
bool output_whether_should_log(Sev sev, const Component &component) const
A key output of Config, this computes the verbosity-filtering answer to Logger::should_log() based on...
Component_payload_type_to_cfg_map m_component_cfgs_by_payload_type
Fast-lookup map from distinct Component_payload type to the config for that component enum.
void store_severity_by_component(component_union_idx_t component_union_idx, raw_sev_t most_verbose_sev_or_none)
Helper that for the given flat-union-component-index saves the given per-component verbosity,...
component_union_idx_t component_to_union_idx(const Component &component) const
Given a component in the form user provides it at log call sites, returns its index in the flat compo...
A simple RAII-pattern class template that, at construction, sets the specified location in memory to ...
Flow module providing logging functionality.
Sev
Enumeration containing one of several message severity levels, ordered from highest to lowest.
@ S_END_SENTINEL
Not an actual value but rather stores the highest numerical payload, useful for validity checks.
@ S_INFO
Message indicates a not-"bad" condition that is not frequent enough to be of severity Sev::S_TRACE.
Basic_string_view< char > String_view
Commonly used char-based Basic_string_view. See its doc header.