23#include <boost/unordered/unordered_flat_map.hpp>
30#ifdef FLOW_DOXYGEN_ONLY
69# define FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_PTR value_for_exposition
101# define FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_VAL value_for_exposition
104# ifndef FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_PTR
105# define FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_PTR Component_payload_type_dict_by_ptr_via_s_hash_map
107# ifndef FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_VAL
108# define FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_VAL Component_payload_type_dict_by_val_via_array
559 template<
typename Component_payload>
561 size_t enum_sparse_length,
562 bool component_payload_type_info_ptr_is_uniq =
false);
646 template<
typename Component_payload>
647 void init_component_names(
const boost::unordered_multimap<Component_payload, std::string>& component_names,
648 bool output_components_numerically =
false,
702 template<
typename Component_payload>
750 template<
typename Component_payload>
867 FLOW_LOG_CONFIG_COMPONENT_PAYLOAD_TYPE_DICT_BY_VAL<Component_config>>;
983 static_assert(std::numeric_limits<component_union_idx_t>::is_integer
984 && (!std::numeric_limits<component_union_idx_t>::is_signed)
985 && (!std::numeric_limits<size_t>::is_signed)
987 "size_t must be able to act as equivalent to a component_union_idx_t key.");
1111template<
typename Component_payload>
1113 size_t enum_sparse_length,
1114 bool component_payload_type_info_ptr_is_uniq)
1116 assert(enum_sparse_length >= 1);
1119 assert(component_union_idx_max >= enum_to_num_offset);
1120 assert(component_union_idx_max >= enum_sparse_length);
1126 { enum_to_num_offset },
1127 component_payload_type_info_ptr_is_uniq);
1151template<
typename Component_payload>
1153 (
const boost::unordered_multimap<Component_payload, std::string>& component_names,
1154 bool output_components_numerically,
1183 for (
auto const & enum_val_and_name : component_names)
1185 const Component_payload enum_val = enum_val_and_name.first;
1187 auto name_sans_prefix_normalized = enum_val_and_name.second;
1188 assert(!name_sans_prefix_normalized.empty());
1191 string name_normalized;
1192 name_normalized.reserve(payload_type_prefix_normalized.size() + name_sans_prefix_normalized.size());
1193 name_normalized += payload_type_prefix_normalized;
1194 name_normalized += name_sans_prefix_normalized;
1214 if (!output_components_numerically)
1217 if (output_name_so_far.empty())
1219 assert(!name_normalized.empty());
1220 output_name_so_far = std::move(name_normalized);
1224 assert(!name_sans_prefix_normalized.empty());
1225 output_name_so_far +=
',';
1226 output_name_so_far += name_sans_prefix_normalized;
1238template<
typename Component_payload>
1254template<
typename Component_payload>
1257 return static_cast<size_t>(Component_payload::S_END_SENTINEL);
void insert(const std::type_info &type, Cfg cfg, bool type_info_ptr_is_uniq)
Adds a mapping from the given type to a Cfg value, so it can be obtained by lookup().
A light-weight class, each object storing a component payload encoding an enum value from enum type o...
unsigned int enum_raw_t
The type Payload must be enum class Payload : enum_raw_t: an enum type encoded via this integer type.
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...
static size_t standard_component_payload_enum_sparse_length()
Returns highest numeric value in the given component-payload enum, plus 1, assuming that enum was cre...
bool m_use_human_friendly_time_stamps
Config setting: If true, time stamps will include a (deterministically formatted) date,...
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...
std::vector< Atomic_raw_sev > Component_union_idx_to_sev_map
Short-hand for fast-lookup, thread-safe-for-RW mapping from flat-union-component-table index to max a...
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.
boost::unordered_flat_map< component_union_idx_t, std::string > Component_union_idx_to_name_map
Short-hand for map that is essentially the inverse of Component_name_to_union_idx_map.
void operator=(const Config &)=delete
For now at least there's no reason for copy assignment.
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.
void init_component_to_union_idx_mapping(component_union_idx_t enum_to_num_offset, size_t enum_sparse_length, bool component_payload_type_info_ptr_is_uniq=false)
Registers a generically-typed enum class that represents the full set of the calling module's possibl...
void init_component_names(const boost::unordered_multimap< Component_payload, std::string > &component_names, bool output_components_numerically=false, util::String_view payload_type_prefix_or_empty={})
Registers the string names of each member of the enum class Component_payload earlier registered via ...
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...
Config(Config &&)=delete
For now at least there's no reason for move-construction.
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...
void operator=(Config &&)=delete
For now at least there's no reason for move assignment.
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...
Config(const Config &src)
Copy-constructs *this to be equal to src config object.
bool configure_component_verbosity(Sev most_verbose_sev, Component_payload component_payload)
Sets the per-component verbosity for the given component to the given value, to be used by subsequent...
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,...
boost::unordered_flat_map< std::string, component_union_idx_t > Component_name_to_union_idx_map
Short-hand for fast-lookup map from normalized component name to its flat-union-component-table index...
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.
void reset(Histogram_counter *target_val, const Histogram_counter &)
Executes target_val->clear(), where *target_val is a Histogram_counter.
bool key_exists(const Container &container, const typename Container::key_type &key)
Returns true if and only if the given key is present at least once in the given associative container...
Basic_string_view< char > String_view
Commonly used char-based Basic_string_view. See its doc header.
unsigned char uint8_t
Byte. Best way to represent a byte of binary data. This is 8 bits on all modern systems.
The set of config stored for each distinct (as determined by Component::payload_type(),...
component_union_idx_t m_enum_to_num_offset
See the enum_to_num_offset arg in init_component_to_union_idx_mapping() doc header.